The connection to my MongoDB database is failing. What should I do?

If you are connecting to a MongoDB 3.x (the default) database on Aptible, either through your app or running aptible db:tunnel, you may hit an error looking like this:

MongoDB shell version: 3.2.1
connecting to:
2016-02-08T10:43:40.421+0000 E QUERY    [thread1] Error: network error while attempting to run command 'isMaster' on host ''  :

exception: connect failed

This error is usually caused by attempting to connect without SSL to a MongoDB server that enforces it, which is the default on Aptible. To solve the issue, connect to your MongoDB server over SSL.

Connection URLs generated by Aptible include the ssl=true parameter, which should instruct your MongoDB client to connect over SSL. If that’s not the case, consult your client’s documentation.

Tunneling with the Aptible CLI is much the same: You will need to pass the the --ssl flag as well as --sslAllowInvalidCertificates. The latter ensures that there are no errors thrown due to a missmatch between the * certificate that we maintain and your localhost (

mongo --ssl --sslAllowInvalidCertificates  -u aptible -p "$PASSWORD" --host --port $PORT

Your Mongo client might not recognize these options unless it is compiled with SSL. If you get an error indicating that SSL isn’t supported, re-install the MongoDB client with SSL support.

If you are unable to resolve the issue, contact support.