MongoDB server 6 on CentOS: Can't add IP bind address


I’ve got an error while trying to bing IP with the config file.

The server ( on CentOS 7) and client ( are WM on the same subnetwork.

The config file was auto created by mongoDB installation, all work except when I change the IP binding line:

No problem with:

  port: 27017
  bindIp: "" #  bindIpAll: true work well too

With BindIpAll I can reach the server with the client.

Fail with:

  port: 27017
  bindIp: ","
  Process: 28566 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=48)
  Process: 28563 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 28561 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 28559 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 27861 (code=exited, status=0/SUCCESS)

I’ve read other post with some IP binding problem which talk about network config.
If need, here ifconfig -a | grep “inet”:

        inet  netmask  broadcast
        inet  netmask

I really appreciate some help.

Have a good Day


Are you using correct IP?
What error you see in the mongod.log
Use server IP instead of client IP you added

1 Like

The above is the solution. You wrote

and you try to bind with

which is the


Thanks a lot for the answers.

I thought that bindIp is to autorize the client IP (external) to connect to the MongoDB server. My MongoDB server is on the and my client is on
So I autorize to connect locally plus an external client (

Could you explain me why autorizing the mongoDB server IP ( will autorize an external connection for a client (

Should I bind:, and ?


You are misunderstanding the meaning of bindIp.

To restrict access based on IP you have to setup a firewall.

Ok I undestand, thanks a lot. Could you give my a real world usage of bindIp in order to understand it?

There are examples in the links I provided.

If you are planning to run your own server I strongly recommend you take M103 from Otherwise Atlas might be a better choice.

Hi @benoit_pont,

By default the mongod process only binds to the localhost ( loopback IP address which limits connections to those originating from the same host. The net.bindIP configuration value enables the process to bind to one or more local network interfaces.

Your real world use case is adding the address to allow non-localhost connections.

You cannot bind to the external IP address; this will result in a startup error for mongod similar to:

Failed to set up listener: SocketException: Can’t assign requested address

The only valid bind IPs are addresses for local network interfaces. For example:

$ ifconfig | grep "inet "
	inet netmask 0xff000000
	inet netmask 0xffffff00 broadcast

Listening to allows any client with an open route to this IP address and port combination to connect.

As @steevej noted, you need to configure a firewall to restrict remote access based on client IPs.

I strongly recommend configuring (and testing) role-based access control and network encryption before opening your deployment to broader network exposure. For more information on available security measures, please review the MongoDB Security Checklist.



Thanks a lot. I really appreciate your precise reply.

Have a nice day

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.