1

I am using MongoDB v3.6.3 on macOS, installed via home-brew. I have used almost every possible way to make my MongoDB server accessible on local network, but to no avail. I have:

  • Turned off firewall on both machines
  • Edited \etc\mongod.conf file to add bindIP.
  • used options-> bind_ip, bind_ip_all (127.0.0.1, 0.0.0.0, other machine's address)

As a matter of fact, also, my redis-server is not accessible on network. I believe there is a common issue in between this. I have tried the above mentioned solutions on macOS High Sierra, Ubuntu 16, Windows 10.

Nabeel Javed
  • 11
  • 1
  • 3
  • It sounds like you're trying to connect to a "remote" database instance, i.e. one that is hosted on a separate machine from your application server. If so, then you should be sure that you're trying to connect using a local IP address or that you have the necessary port forwarding and/or firewall configuration set up. Please provide further information regarding your setup and configuration, because right now we can only speculate as to what your issue might be. – B. Fleming Mar 30 '18 at 19:56
  • You've listed several operating systems which don't work: can you narrow down the description to a single test case to start with? Can you include the IP address of your macOS machine and the remote you are trying to connect from? I assume both are private IPs on the same network. Note: the `bind_ip` directive only applies to local IP addresses a `mongod` can listen to: `used options-> bind_ip, bind_ip_all (127.0.0.1, 0.0.0.0, other machine's address)`. You should have either `bind_ip` with a list of local addresses to listen to, or `bind_ip_all` (but not both settings). – Stennie Mar 30 '18 at 23:46
  • Can you also include the command line you are using to test connectivity and any specific error messages or output? I would use the `mongo` shell as a simple test before trying any third party tools or drivers. It would be helpful to confirm the shell version (`mongo --version`); ideally this should match your server version. – Stennie Mar 30 '18 at 23:48
  • what is the output of `netstat -antu | grep redis` and `netstat -antu | grep mongo` ? – MD Ruhul Amin Mar 31 '18 at 14:33

2 Answers2

1

I have been facing the same error. You could allow external access using the following parameters when starting your server:

mongod --bind_ip_all // Allow any ip

or

mongod --bind_ip <your_ip_here>
albertTaberner
  • 1,969
  • 1
  • 26
  • 35
0

Open MongoDB config file.

Add the below command in that file(mongod.conf) and save it.

Mac config file location is : /usr/local/etc/mongod.conf

net:
    bindIp: 0.0.0.0

Important Note: Once saved please restart the MongoDB services then only it will work.

Bharathi Devarasu
  • 7,759
  • 2
  • 18
  • 23