Mongodb Compass: Connection timed out

I installed Mongodb on my remote server using this documentation. I have Ubuntu 16.04 on my remote server. Mongodb got installed successfully. I added the user like this:

use admin
    user: 'myuser',
    pwd: 'password',
    roles: [ { role: 'readWrite', db: 'mydb' } ]

I also made changes in the mongod.conf like this:

  port: 27017

  authorization: 'enabled'

Now when I try to connect to mongodb using conneciton string like this:


It gives me the following error:

connection timed out

What am I doing wrong here? I am using Laravel Forge to manage sever.

Can you connect by shell remotely as well as locally using same srv connect string?
Is port 27017 open to connections
Could be firewall blocking your connection

1 Like

I am not using the srv string as you can see in the question. Aftter ssh-ing into the server, I can connect to mongodb using the same string. There is no firewall blockage as I can connect to server from the same host but cant connect to mongodb. And this is the result of telnet:

telnet 27017
telnet: Unable to connect to remote host: Connection timed out

Just for testing use for bindIp and see if you can connect
Do you have the option to fill in individual params instead of connect string?
Use advance options and check ssh tunnel
Try different options

1 Like

As it turned out the port was not open and that was the only issue. Opened the port and now its working fine.

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