awsmongodb

Connect to MongoDB from a different machine

For security reasons, the MongoDB port in this solution cannot be accessed over a public IP address. To connect to MongoDB from a different machine, you must open port 27017 for remote access. Refer to the FAQ for more information on this.

IMPORTANT: By default, the database port for the nodes in this solution cannot be accessed over a public IP address. As a result, you will only be able to connect to your database nodes from machines that are running in the same network. For security reasons, we do not recommend making the database port accessible over a public IP address. If you must make it accessible over a public IP address, we recommend restricting access to a trusted list of source IP addresses using firewall rules. For development purposes, you can also use a VPN or SSH tunnel. Refer to the FAQ for information on accessing restricted ports using an SSH tunnel or opening ports in the server firewall.

Once you have an active SSH tunnel or you opened the port for remote access, you can then connect to MongoDB using a command like the one below.

Remember to replace SOURCE-PORT with the source port number specified in the SSH tunnel configuration or 27017 if you opened the port for remote access.

$ mongo admin --username root -p --host 127.0.0.1 --port SOURCE-PORT
Last modification April 8, 2020