Issue with connecting the db deployment remotely

I have installed and set up a DB deployment on a RedHat Linux VM. In the config file I already enable access from anywhere by setting bindIp to 0.0.0.0. when I try to connect the DB deployment using the VM by mongosh mongodb://<credential>@<hostname>:<port>/, it works fine. However, when I ran the same command on my window PowerShell, I got MongoServerSelectionError: connect ETIMEDOUT error. I am using SSL VPN because the port is only open inside certain network. Any suggestion on possible causes of the connection etimeout error or suggestion will be appreciated. Thank You!

mongosh logs:

{"t":{"$date":"2023-09-22T04:48:46.471Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"<host>:<port>","failure":"connect ETIMEDOUT <host>:<port>","isFailFast":false,"isKnownServer":true}}
{"t":{"$date":"2023-09-22T04:48:55.439Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"<host>:<port>","failure":"connection establishment was cancelled","isFailFast":false,"isKnownServer":true}}

Sounds like you’re firewalled out. Almost certainly TCP/IP problems, whatever.

can you please check if iptables/firewalls are blocking?

hi @ROHIT_KHURANA


is that what you mean? if I am not mistaken, the port should be listening

update:


I tried talent on my window11 local machine. It seem like the connection failed on my local machine. The Chinese text is saying “cannot connect to host, port 3389 connection fail”

Here are some updates on what I have done based on the comment so far:

  1. disable the firewall by systemctl disable firewalld
  2. check whether the port that runs mongod is listening by netstat -tulpn and it is listening

I have tried all the solutions above but still failed to establish the connection. any more suggestions will be appreciated.

Are you sure the problem isn’t on the Windows side?
Built-in Windows firewall?
Is this a company-managed Windows PC?
Check with your IT department whether or not you can connect to arbitrary remote ports.

@Jack_Woehr Thank you for your reply again. I am using my own PC. I believe the problem should be on the server side since I tried to establish a connection with Mongo Atlas and it works fine.

@Samson , it seems to me that there are small number of possibilties:

  • The MongoDB configuration does not listen on the external port?
    • It looks like the MongoDB configuration is correct, so this does not appear to be the problem.
  • IPTables on the Linux VM prevent the connection?
    • You have disabled IPTables on the VM, so this does not appear to be the problem.
  • Your Windows PC is firewalling you out?
    • You can connect to Atlas, so this does not appear to be the problem.

All that remains, as far as I can guess, is that the SSL VPN you are on is firewalling you out of the MongoDB port on the Linux VM. Other than that, I’m currently out of guesses :confused:

@Jack_Woehr Thank you for summarizing all the possibilities. I will just mark your reply as the solution. In case someone has a similar problem, they can follow your suggestion.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.