Troubleshooting connection issues

Can’t connect to new database or consistent connection issues to existing database

Is it a network access issue?

Make sure you have network access to the port on which your database’s server process is running. You can get the database server address (hostname:port) from your deployment’s connection string.

How to check network access

The best way to test network connectivity is by using nc (netcat) or telnet. For example:

% nc -w 3 -v ds012345.mlab.com 12345

If you have network access, you will see output like the following:

Connection to ds012345.mlab.com port 12345 [tcp/*] succeeded!

Alternatively, if you’re connecting from a machine that has access to a browser, you can also enter your database server’s address into your browser’s address bar and connect from there. For example:

http://ds012345.mlab.com:12345

If you have network access, you will see output like the following in your browser:

It looks like you are trying to access MongoDB over HTTP on the native driver port

If this browser test fails, ensure that the database is up and running by logging into our management portal and viewing it there.

If you can’t connect because of a network access issue:

Is it a connection configuration issue?

If everything is fine from a network perspective, the next thing to check is your connection settings. Use the mongo shell to debug connection details. For example:

% mongo ds012345.mlab.com:56789/dbname -u dbuser -p dbpassword
MongoDB shell version: 3.2.11
connecting to: ds012345.mlab.com:56789/dbname 
Mon Apr 23 11:41:20 uncaught exception: login failed 
exception: login failed

Is it a version (driver/shell) compatibility issue?

If everything is fine from a network perspective and the database credentials you’re using are correct, the next thing to check is whether you are connecting and authenticating using a compatible method.

An common issue caused by version compatibility is the support for the SCRAM-SHA-1 authentication mechanism in MongoDB 3.0 or above. To elaborate, the release of MongoDB 3.0 included support for the SCRAM-SHA-1 challenge-response user authentication mechanism, which changed how MongoDB uses and stores user credentials. Clients connecting to an mLab database running MongoDB 3.0 or above must do so using drivers or mongo shells which also support SCRAM-SHA-1.

Is an issue with network latency/instability?

For network latency and security reasons, we strongly recommend that you connect from the same region as your database. If this is not possible, make sure you are connecting from a region closest to your database to reduce latency.

Sudden or intermittent connection issues to an existing database

If you are experiencing sudden or intermittent connection timeout/failure to a database that you had connected to previously, and have not changed your network settings or updated your driver, follow these troubleshooting tips:

Is it the database?

Is it the network?

If the issue does not appear to be related to the database, check for network issues that could cause the connection problem.

Is it the application/drivers?

It is important to note the time when your connection issue occured and to correlate that with what is shown in the server logs, Telemetry graphs, or current operations view.

Still having problems?

If you know you have network access and the correct credentials and you’re still having problems connecting, contact us at support@mlab.com and be sure to include your connection details (e.g., hostname/server, port, database name).