Mongodb "connection timed out" when connect from remote system

153 Views Asked by At

I have a Ubuntu 22.04.2 LTS vps and I have following configs for firewall.

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 27017                      ALLOW IN    Anywhere                  
[ 2] Nginx Full                 ALLOW IN    Anywhere                  
[ 3] 27017 (v6)                 ALLOW IN    Anywhere (v6)             
[ 4] Nginx Full (v6)            ALLOW IN    Anywhere (v6)   

in /etc/mongod.conf file i have bind ip to follwoing: bindIp:127.0.0.1,_server_ip I tried by setting bindIp to 0.0.0.0 as well.

I am not able to access mongdb with mongo compass or cli as well. It gives me connection timed out after some time.

When I initially setup mongdb on vps it was working after few days it has stop working.

When i run following command:

sudo netstat -tuln | grep 27017

it gives me following output:

tcp        0      0 149.102.243.111:27017   0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN

when i disable firewall I am able to connect with database from remote system as well. I am not sure what is blocking it.

0

There are 0 best solutions below