You can use these credentials to authenticate the following nodes with MongoDB:
Create a user account with the appropriate permissions on a MongoDB server.
Using connection string or values#
Choose how to connect to MongoDB by selecting the type of connection in Configuration Type. For formatting details for Connection String, refer to Connection String URI Format.
Connecting to MongoDB Atlas#
You need to configure your MongoDB database, then configure your n8n credential.
MongoDB Atlas settings#
- Inside your MongoDB organization, set up your database cluster. Your cluster will be visible in Organization > Project, in the Database section.
- Inside the cluster, you need to have a database to connect to. If you don't have a database yet, you can go to Collections and select Add My Own Data. A dialog will show up: enter the name of the database in the Database name field and the name of the collection in the Collection name field.
- Once ready, you'll see the database in Organization > Project > Databases > Collections.
- In the Network Access section of your project you need to allow list the n8n IPs. Select Add IP Address button and add all the IPs listed here. The allow list IPs will be visible in the IP Access List table.
- In MongoDB Atlas, go to the cluster page and select Connect. A dialog will open. Select Drivers.
- In the MongoDB dialog, copy the code you see in Add your connection string into your application code. It will be something like:
mongodb+srv://yourName:yourPassword@clusterName.5j5fpzo.mongodb.net/?retryWrites=true&w=majority. You can find details on how to format the connection string here.
- In the MongoDB credential dialog set Configuration Type as Connection string.
- Paste the code you copied from the MongoDB dialog in the Connection String parameter in the n8n dialog.
<password>with your user's password.
- Input the name of the database you created in the Database field.
- Click Save. A green box will confirm the connection was successful.