2

I'm using mongodb v4.2.3 for ubuntu, and i'm trying to bind localhost and my public ip, but i get an error every time i reload mongodb afther editing the configuration file.

bind_ip = 127.0.0.1
port = 27017

the error while restarting mongodb:

Job for mongodb.service failed because the control process exited with error code.
See "systemctl status mongodb.service" and "journalctl -xe" for details.
  • what error do you get? Add it to the question. – Aritra Chakraborty Mar 29 '20 at 20:53
  • Does this answer your question? [How to set mongod.conf bind\_ip with multiple ip address](https://stackoverflow.com/questions/29109134/how-to-set-mongod-conf-bind-ip-with-multiple-ip-address) – Joe Doyle Mar 29 '20 at 20:54
  • I think your approach is wrong. You do not need to bind mongo to multiple ip addresses. Binding to 127.0.0.1 be enough. At that point I believe you just need to configure your firewall to allow external traffic to access port 27017 on your machine. I've done similar things like on windows. See https://docs.mongodb.com/manual/tutorial/configure-linux-iptables-firewall/#manage-and-maintain-iptables-configuration – 88jayto Mar 29 '20 at 22:37
  • Not working, i've already opened port 27017 in my firewall, but when i try to connect to it remotely, i get "connection refused" – Nicolò Rancan Mar 30 '20 at 08:16
  • here is someone who had a similar issue: https://stackoverflow.com/questions/28788740/opening-a-port-on-ubuntu – 88jayto Mar 30 '20 at 19:09

1 Answers1

1

Solved.

bind_ip = 127.0.0.1

For single ip, because it's interpreted as number

bind_ip = "127.0.0.1,xxx.xxx.xxx.xxx"

For multiple ip, because it's interpreted as string