By default, the MongoDB One-Click application is secured with a UFW-managed firewall. In order to allow your Node application to access the MongoDB instance, you must open a port in the firewall. This command will allow access from the Node app’s IP address and nowhere else:
- sudo ufw allow from node_ip_address to any port 27017
Additionally, MongoDB is configured to only listen on the local interface by default. To allow remote connections, modify the value of bindIp
in /etc/mongod.conf
If you do so, you are highly advised to first review the security checklist from the MongoDB documentation. In addition to enabling one of the forms of authentication supported by MongoDB.
The relevant section of the config file should look like:
# [ ... ]
net:
port: 27017
bindIp: 127.0.0.1,ip_of_mongo_droplet
# [ ... ]
For more information on running MongoDB, including enabling authentication, check out:

by Hazel Virdó
UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall. While iptables is a solid and flexible tool, it can be difficult for beginners to learn how to use it to properly configure a firewall. If you're looking to get started securing your network, and you're not sure which tool to use, UFW may be the right choice for you. This tutorial will show you how to set up a firewall with UFW on Ubuntu 16.04.