In a nutshell, I can’t connect to mongodb from my VPS. Tho I can from my pc and Heroku.
- Are all ports open ? Yes
- Is there any firewall/VPN ? No
- Does the VPS have static IP : Yes
- Which IP is allowed on Network Access ? 0.0.0.0/0
- Tried changing the DNS ? Yes, tried both Google and Cloudflare
resolvectl status
Global
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Current DNS Server: 8.8.8.8
DNS Servers 8.8.8.8 8.8.4.4
Link 2 (eth0)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 3 (docker0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
- Can I connect to :27017 ? yes
curl portquiz.net:27017
Port test successful!
Your IP: [IP]
- Tried using the old connection string ? Yes
edm115@VPS:~/unzip-bot$ mongosh $MONGODB_URL
Current Mongosh Log ID: 65f94ff55c890d27f9c72f04
Connecting to: mongodb+srv://<credentials>@unzip-bot-cluster.abcde.mongodb.net/unzipDB?retryWrites=true&w=majority&appName=mongosh+2.2.0
MongoServerSelectionError: Server selection timed out after 30000 ms. It looks like this is a MongoDB Atlas cluster. Please ensure that your Network Access List allows connections from your IP.
edm115@VPS:~/unzip-bot$ mongosh $MONGO_URI
Current Mongosh Log ID: 65f9501eecdaae1be0c72f04
Connecting to: mongodb://<credentials>@unzip-bot-cluster-shard-00-00.abcde.mongodb.net:27017,unzip-bot-cluster-shard-00-01.abcde.mongodb.net:27017,unzip-bot-cluster-shard-00-02.abcde.mongodb.net:27017/unzipDB?retryWrites=true&w=majority&appName=mongosh+2.2.0
MongoServerSelectionError: connection <monitor> to 65.52.148.81:27017 closed. It looks like this is a MongoDB Atlas cluster. Please ensure that your Network Access List allows connections from your IP.
So far I feel like I’ve tried everything. Connecting with a driver (to check if it is a mongosh error) isn’t any better :
Error in main loop:
SSL handshake failed:
unzip-bot-cluster-shard-00-01.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),
SSL handshake failed:
unzip-bot-cluster-shard-00-00.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),
SSL handshake failed:
unzip-bot-cluster-shard-00-02.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms),
Timeout: 30s,
Topology Description:
<TopologyDescription id: 65f799042447913c4e692b94,
topology_type: ReplicaSetNoPrimary,
servers: [<ServerDescription
('unzip-bot-cluster-shard-00-00.abcde.mongodb.net', 27017) server_type: Unknown,
rtt: None,
error=NetworkTimeout('SSL handshake failed:
unzip-bot-cluster-shard-00-00.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>,
<ServerDescription
('unzip-bot-cluster-shard-00-01.abcde.mongodb.net', 27017) server_type: Unknown,
rtt: None,
error=NetworkTimeout('SSL handshake failed:
unzip-bot-cluster-shard-00-01.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>,
<ServerDescription
('unzip-bot-cluster-shard-00-02.abcde.mongodb.net', 27017) server_type: Unknown,
rtt: None,
error=NetworkTimeout('SSL handshake failed:
unzip-bot-cluster-shard-00-02.abcde.mongodb.net:27017:
_ssl.c:989: The handshake operation timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
Really a pain, trying to fix this since 5 days, so if anyone can help me I’d be very grateful ![]()