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
Asked
Active
Viewed 525 times
0

Corioste
- 1
-
You REALLY don't want an open mongo server sitting on the internet for world + dog to abuse – Timothy c Apr 28 '21 at 17:58
-
i just want to test my server first then once i get connected i will setup everything firewall etc ..... – Corioste Apr 29 '21 at 00:42
-
Is mongo listening on port 27107? Use `netstat -nap` to find out. – Andrew Schulman Apr 30 '21 at 14:48
1 Answers
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