MongoDB port listening in loopback ip address when restarting the system

Hello Team,

I am facing the timeout exception for the following steps,

  1. Restart the system
  2. Communicate mongoDB from one of the windows service throws timeout exceptions.

While analysis I found that the mongoDB port listening the loopback ipaddress when restarting the system. At this point I am getting the timeout exception.

After restarting the system, I tried restarting the MongoDB service also. It started listening with ipv4 Address and port. And communication works properly.

My question here is, why the MongoDB is taking loopback ipAddress while restarting the system.

Any helping hands??

MongoDB version - 4.0.10

C# dll version

MongoDB.Bson -
MongoDB.Libmongocrypt -

Best Regards,

Read about the configuration option net.bindip

Hi Jack,
Thanks for response.
Yes I tried bindIpAll parameter and it solved the issue.

But my doubt here is, why MongoDB service is taking loopback ipAddress while restarting PC? is it possible to clarify this?

bindIpAll: true means “use all interfaces, including the loopback”.
If you just want the interface then

bindIpAll: false

Hi Jack,
So everytime when the PC is restarted will MongoDB start using loopback address?

If you say bindIpAll: yes, then it will.

Hi Jack,

Coming back to my first question.

I have created the service initially with the following parameter

“C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe” -f “C:\Program Files\MongoDB\Server\mongodb_config.yml” --bind_ip=hostname --port=9876 --serviceName “MongoDB” --serviceDisplayName “MongoDB” --serviceDescription “MongoDB Server” “–dbpath=C:\data” “–logpath=C:\data\log.txt” --service

Here I have used only --bindip paramater which has the value of fully qualified hostname.

after service created, it started listening with ipv4 static address(ex: with the port 9876.

Now, I am restarting the PC, my expectation is that the port 9876 should listen in the same ipv4 static address(ex: But it is listening with loopback ipAddress Due to this communication is not happening and timeout exception is occuring.

Why this difference happening in MongoDB component? or what should I change to make it works properly?

Most likely you have Windows default service active which brings up mongod on default port 27017 and localhost on reboot
What you started is a service from command line but is it configured for autostart?
You can check your current mongod service in taskmanager.Does it match with your manually started service?

I have removed the default service. And then I created the new service with this command line and set it as autostart by default.

any inputs for this query?

I thought your issue got resolved after making the new service as default
Your bindIp could be the issue.It cannot be FQDN
You have to give your network interface IP

I have tried bindip with network interface address as well. But after restarting the System, MongoDB service is not started automatically. Service is set to auto start only. So Manual restart is required.

It is not solved my issue.

Can you tell us, when MongoDB service will take loopback ipaddress or which kind of environment makes the MongoDB port to listen with loopback ipaddress.

If it is configured to start auto why manually mongod is being started?
I think you have to review your service creation
When you are passing config file your mongod why again command line params are being passed?
First you have to create cfg file
Then create service referring to above cfg file with install option
Then configure it as auto start