0

I created a virtual machine ubuntu18.04 and install mongodb using sudo apt install -y mongodb then uncomment PORT in .conf then change 127.0.0.1 to 0.0.0.0 then restart mongodb then when i try to remote login i received this error 2021-04-23T14:07:12.438+0800 E QUERY [thread1] Error: couldn't connect to server my_ip:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed I didnt setup any firewall i want first to test my connection

1 Answers1

0

To allow remote connections, you must edit the MongoDB configuration file — /etc/mongod.conf — to additionally bind MongoDB to your machine's publicly-routable IP address. This way, your MongoDB installation will be able to listen to connections made to your MongoDB server from remote machines.

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1,mongodb_server_ip

Please note that this should be the IP address of the Machine on which you’ve installed MongoDB. That is the Machine should have publicly routable Ip address

Nimal V
  • 17
  • 3