mongdb string url I cannot connect to the primary ...
# replication-ask-ai
r
mongdb string url I cannot connect to the primary node timeout
k
MongoDB Connection Timeout to Primary Node This is a common issue with the Airbyte MongoDB connector. Here are the most likely causes and solutions: 1. Check Network Reachability Ensure your MongoDB instance is reachable from the network where your Airbyte instance is running. A
SocketTimeoutException
or
MongoSocketOpenException
typically indicates a network/firewall issue. [Forum: Salesforce and Mongo] 2. SSL/TLS Misconfiguration A frequent cause of primary node timeouts is an SSL handshake failure. The error typically looks like:
Copy code
Timed out after 30000 ms while waiting for a server that matches 
ReadPreferenceServerSelector{readPreference=primary}...
caused by {javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}
Possible fixes: • Verify whether SSL is enabled on your MongoDB server and match your Airbyte configuration accordingly. • If connecting to a local or self-hosted cluster without SSL, make sure you are not forcing SSL in the connection string. [GitHub Issue: SSLHandshakeException] • If SSL is required, ensure the correct certificates are trusted by the connector. [Forum: Self Signed Cert] 3. replicaSet Parameter Missing If you're using a self-managed replica set, the connector requires the
replicaSet
parameter in the connection string. Without it, CDC and primary node selection can fail:
Copy code
mongodb://<host>:<port>/?replicaSet=<your-replica-set-name>
[GitHub Issue: replicaSet not handled] 4. Read Preference Configuration The connector defaults to selecting a primary node. If the primary is unreachable or under load, you can try routing reads to a secondary:
Copy code
mongodb+srv://cluster0.abcd1.mongodb.net/?readPreference=secondaryPreferred
[MongoDB Troubleshooting Docs] 5. Verify Your Connection String For MongoDB Atlas, follow the official guide to get the correct connection string. For self-hosted clusters, refer to the MongoDB connection string documentation. [MongoDB Source Docs] Summary checklist: • MongoDB is network-accessible from Airbyte's host • SSL setting in Airbyte matches the MongoDB server configuration •
replicaSet
parameter is included in the connection string (self-hosted) • Firewall/security group allows traffic on port 27017 If you share your specific connection string format and error logs, I can help narrow down the issue further. 👍 0 button 👎 0 button ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.