I am trying to set remote access for my fresh installed mongod service but it is turning impossible by now.
Database works just fine local but there is no way to make it works remote. These are the steps I have already tried it:
1- I set up Oracle subnet to allow 27017/tcp traffic.
2- Able 27017/tcp traffic in the Oracle Compute firewall.
3- Set up the mongod.conf bindIp property to 0.0.0.0
After that mongod service fails to startup.
Then I changed the bindIp property to my public Oracle Compute ip address and it fails as well.
After that I used the internal ip address of the Oracle Compute, bindIp: 10.0.0.151
$ ip a | grep "net"
Output:
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 10.0.0.151/24 brd 10.0.0.255 scope global enp0s3
inet6 fe80::17ff:fe0c:78d6/64 scope link
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
The mongod service now startup properly but it is not possible to connect to the database from a remote system. I get the following error when trying to connect from my desktop system using mongosh on windows 11.
MongoServerSelectionError: connect ETIMEDOUT server_ip:27017
I would really appreciate any help. Thanks.
2
Answers
Do you have egress security rule? Is there an NSG in place? Do you have IG and proper routing?
Can you create a network stack and post it?
PS: Autonomous DB now comes with MongoDB API, you can try that as well.
I don’t know if you still need help, but just in case if you do and for anyone in the future that may have a similar issue, I just got my remote connection to my OCI (Oracle Cloud instance) MongoDB server working.
Here are the steps I took to get it working.
You first need to have an Ingress Rule in the Default Security List for your OCI’s subnet to allow TCP connections from your remote computer IP (the computer that will connect remotely to your OCI) to port number 27017 (Mongo’s default port unless you changed it).
To get to the page to setup an Ingress Rule follow this article from steps 1-7:
Inside of your OCI (aka you’ve SSH into it), setup Mongo’s config file.
Restart Mongo Service and check that it’s running.
sudo systemctl restart mongod
sudo systemctl status mongod
sudo systemctl start mongod
Lastly, we need to set up the firewall permissions.
sudo ufw status
. It should show it as inactive. If it’s active, you can disable it with the commandsudo ufw disable
. Then check the status of it again to make sure it’s disabled.sudo apt install firewalld
sudo firewall-cmd --add-port PORT#/tcp --permanent
while changing PORT# to the port of your Mongo server. The –permanent tag makes the rule exist even after the firewall is reloaded or if the OCI is rebooted. An example of the command using the default Mongo server port issudo firewall-cmd --add-port 27017/tcp --permanent
sudo firewall-cmd --remove-port 27017/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
and under ports, you should see the port you added. Now from your remote computer, you should be able to connect to the Mongo server on your OCI by using the public IP address of your OCI (the same address you used to connect to the OCI through SSH).