Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

IP Binding

On this page

  • Overview
  • Considerations

Starting in MongoDB 3.6, MongoDB binaries, mongod and mongos, bind to localhost by default. If the net.ipv6 configuration file setting or the --ipv6 command line option is set for the binary, the binary additionally binds to the localhost IPv6 address.


Make sure that your mongod and mongos instances are only accessible on trusted networks. If your system has more than one network interface, bind MongoDB programs to the private or internal network interface.

To override and bind to other ip addresses, you can use the net.bindIp configuration file setting or the --bind_ip command-line option to specify a list of hostnames or ip addresses.


Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.

For example, the following mongod instance binds to both the localhost and the hostname My-Example-Associated-Hostname, which is associated with the ip address

mongod --bind_ip localhost,My-Example-Associated-Hostname

In order to connect to this instance, remote clients must specify the hostname or its associated ip address

mongo --host My-Example-Associated-Hostname
mongo --host

To bind to all IPv4 addresses, you can specify the bind ip address of To bind to all IPv4 and IPv6 addresses, you can specify the bind ip address of ::, or alternatively, use the new net.bindIpAll setting or the new command-line option --bind_ip_all.


See also:

← Network and Configuration Hardening