Allow Remote Access to MongoDB

Database

Out of the box, MongoDB doesn’t allow remote connections, because by default it has no authentication enabled and is listening on localhost only.

If you try to connect to MongoDB without remote access being allowed, you will get this error:

In this article i will show how to allow remote access to MongoDB.

Allow Remote Access to MongoDB

By default, MongoDB is listening on 127.0.0.1:27017 only:

Open MongoDB configuration file /etc/mongod.conf and change bindIp by adding required LAN interfaces or configure it to bind to all interfaces, for example:

Restart mongod to apply modifications:

Now mongod is listening on configured interfaces and can be accessible remotely:

Source: https://www.shellhacks.com/mongodb-allow-remote-access/

Share: