Quiz: The mongos configuration file doesn't need to have a port

Hi. I don’t get that question. The mongos has a default port number: 27017. So if not specified (even in the config file), that value is used. So I would say, the statement “The mongos configuration file doesn’t need to have a port” is true. But it turned out that was false: “Every mongos (and mongod) process needs to be assigned a port to run on”. So the config file for mongos has to always have a port regardless there is a default value?

Hi @Piotr_Dros_38199,

mongod and mongos are two different processes with different utility. mongod runs on the port 27017 by default if no port is specified because either this value is hard coded in the binaries or this value has been specified in the default configuration file.

In essence, all the mongod and mongos process needs to be assigned a port to run on ( either you mention it or it uses the default options).

If you are curious to know if mongod uses any other default ports then here is the list:

Hope it helps!

If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

The documentation also states that the default port for mongos instance is 27017:
https://docs.mongodb.com/manual/reference/default-mongodb-port/
https://docs.mongodb.com/manual/reference/configuration-options/#net.port

I believe that the point that @Piotr_Dros_38199 is making is that in the quiz for Setting up a Sharded Cluster in Chapter 3, one of the options is unclear. It states that “The mongos configuration file doesn’t need to have a port”, which implies that net.port is mandatory in the config file, however, there’s nowhere in the documentation that explicitly states that the mongos config file must specify a port in its config file. Had the words “config file” not been part of that sentence, it would have been more acceptable. I suppose, this is feedback.

Hi, thanks for the answer. That’s clear that always must be port assigned to the process (mongos, mongod, etc…). However the statement “The mongos configuration file doesn’t need to have a port” is not clear for me. As I understood, the configuration file does not need to have a port, because in that case the default value is used. But, according to the quiz, this is a bad answer.

Hi @Piotr_Dros_38199,

Sorry any misunderstanding this might have caused. Thanks for surfacing this issue. We will look into it.

Thanks,
Shubham Ranjan
Curriculum Support Engineer