- MongoDB 2.6
- MongoDB 3.2, 3.4, 3.6
- MongoDB 4.0
Connecting to MongoDB
Aptible MongoDB Databases require authentication and SSL to connect.
📘 MongoDB databases use a valid certificate for their host, so you're encouraged to verify the certificate when connecting.
Connecting to the
There are two MongoDB databases you might want to connect to:
dbdatabase created by Aptible automatically.
The username (
aptible) and password for both databases are the same. However, the users in MongoDB are different (i.e. there is a
aptible user in the
admin database, and a separate
aptible user in the
db database, which simply happens to have the same password).
This means that if you'd like to connect to the
admin database, you need to make sure to select that one as your authentication database when connecting: connecting to
db and running
use admin will not work.
MongoDB replica sets will automatically failover between members. In order to do so effectively, MongoDB recommends replica sets have a minimum of three members. This can be done by creating two Aptible replicas of the same primary Database.
The connection URI you provide your Apps with must contain the hostnames and ports of all members in the replica set. MongoDB clients will attempt each host until it's able to reach the replica set. With a single host, if that host is unavailable, the App will not be able to reach the replica set. The hostname and port of each member can be found in the Database's Credentials, and the combined connection URI will look something like this for a three-member replica set:
Data Integrity and Durability
On Aptible, MongoDB is configured with default settings for journaling. For MongoDB 3.x instances, this means journaling is enabled. If you use the appropriate write concern (
j=1) when writing to MongoDB, you are guaranteed that committed transactions were written to disk.
Configuration of MongoDB command line options is not supported on Aptible.
Aptible MongoDB Databases support connections via the following protocols:
- For Mongo versions 2.6, 3.4, and 3.6:
- For Mongo version 4.0: