I built a Node.js RestAPI that communicates with a MongoDB. I've deployed this into a host machine. Everything is working, I can use my application and communicate with the RestAPI that writes data into the MongoDB database.
However, I'm trying to get the MongoDB compass on my PC to connect to the MongoDB on the host machine, so I can see the DB in a more user-friendly way, but no matter what I try, I can't get compass to connect with the DB on the host machine.
Mongod is running on 127.0.0.1:27017 on the host machine but accepts external requests. The server has a public IP address, which is in use in the application and works, however, no matter what hostname I try it always says MongoDB isn't running on provided host and port. The host machine is running Ubuntu 16.04.
Can anyone please tell me what are the parameters I need to fill on compass in order to get it to connect?
I've read the documentation, but to no avail.
Thank you!
If you would like to connect to your MongoDB
from difference machine, I think maybe some reasons make this happen:
Do you have make sure Port 27017
is already open for remote access on your Ubuntu firewall setting (UFW)?
If no, You can try ufw allow 27017
. But I don't really recommend this way for security reason; You can do Port forwarding by iptable
.
Do you have turn on Remote Access
in your MongoDB configuration? Check This Out