, free & fully virtual. June 9th - 10th. Register Now

I can't set bindIp


I’m just starting MongoDB, so i need a lot of help. :cry:

Now, I’m setting ‘net.bindIp’ in mongodb.conf, but it doesn’t seem like it.

I know that ‘net.bindIp’ determines what ip to access DB like AWS’s inbound setting.

So, I did various tests.

  1. net.bindIp : localhost.
  • mongod -f /etc/mongod.conf is well
  • But, MongoDB Compass cannot access to DB.
  1. net.bindIp : instance IP(this is aws instance private ip. hostname -I command result).
  • mongod -f /etc/mongod.conf is well
  • And, MongoDB Compass can access to DB well.
  1. net.bindIp : my computer IP
  • mongod -f /etc/mongod.conf is error(Error: 48)

Below is error content.

about to fork child process, waiting until server is ready for connections.
forked process: 29977
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the "--fork" option.

So, I have a few questions.

  • Why can’t I connect ‘bindIP : localhost’ with MongoDB Comapss when I can connect ‘bindIp : instance IP’ with MongoDB Compass?

  • Why can’t I set my computer IP with net.bindIp?

Below is my mongod.conf setting, and my MongoDB version is v4.2.6

I just modified ‘net’ and ‘security’.

# mongod.conf

# for documentation of all options, see:

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
  dbPath: /var/lib/mongo
    enabled: true
#  engine:
#  wiredTiger:

# how the process runs
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
  port: 27017
  bindIp: localhost  # I tested this.(localhost, instance ip, my computer ip)

  authorization: enabled
  javascriptEnabled: false




## Enterprise-Only Options



Thank you!

Welcome to the MongoDB Community, @DongHyun_Lee!

That’s actually an incorrect assumption. The bind_ip configuration value only determines which local IP address(es) your MongoDB server is listening to. It does not control access from remote IPs – that is the job of a firewall (like your AWS Inbound rules).

The only valid values for bindIp are local network interfaces for the MongoDB process. For example, on Linux any local IPs would appear in the output of ifconfig -a | grep "inet".

If you want to connect from your Compass on your local computer to a remote MongoDB deployment on AWS, you need to set up a secure connection. Typically this is done via VPN or SSH port forwarding, so your database instance is not directly exposed to the internet. In this case your mongod instance would only need to listen to localhost (for ssh) and the private IP (for VPN or ssh via a jump host on the same private network).

For more information on available security measures, please review the MongoDB Security Checklist.

If you review your MongoDB logs, I expect you’ll find a message like:

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

This message indicates you are trying to bind to an address that is not a valid local network interface, and will be the reason your MongoDB process is unable to start.



Thank you Stennie! I understand :smile:. Have a nice day!

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