Unable to connect to MongoDB from a VPN

My Mongo database is hosted on MongoDB Atlas cloud server. I am unable to connect to the server when I am on VPN(company network). When I disconnect from the VPN and try, it works fine. I have tried through multiple options, from Mongo Compass, command line, through code snippet. It’s the same problem.

I have whitelisted my public IP address on the Mongo Atlas server but still unable to connect.

On Mongo Compass I get the following error :
Connection URI : mongodb+srv://<username>:<password>@<hostname>

Error : connect ECONNREFUSED 52.42.97.161:27017

From command line : Command : mongo "mongodb://<hostname>:27017" --ssl --authenticationDatabase admin --username <username> --password <password>

Error : W NETWORK [thread1] Failed to connect to 54.148.205.233:27017 after 5000ms milliseconds, giving up.
W NETWORK [ReplicaSetMonitor-TaskExecutor-0] No primary detected for set Field-shard-0
I NETWORK [ReplicaSetMonitor-TaskExecutor-0] All nodes for set Field-shard-0 are down. This has happened for checks in a row.
W NETWORK [thread1] Failed to connect to 34.211.199.170:27017 after 5000ms milliseconds, giving up.
W NETWORK [thread1] No primary detected for set Field-shard-0
I NETWORK [thread1] All nodes for set Field-shard-0 are down. This has happened for 2 checks in a row.
E QUERY [thread1] Error: connect failed to replica set Field-shard-0/field-shard-00-00.xvwf9.mongodb.net:27 17,field-shard-00-01.xvwf9.mongodb.net:27017,field-shard-00-02.xvwf9.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed

Please let me know what I can try to make this work. Thanks!

1 Like

Sounds like a firewall is blocking the ports.

1 Like

Sorry if this is too basic to ask but where can I check and modify that?

@Syed_Muthahar , that’s an Amazon address so whoever manages your Amazon networking would know the answer.

2 Likes