The database industry has undergone a number of changes in recent years, resulting in a greater shift toward a Database as a Service (DBaaS) model versus On-Premise Infrastructure. Most business apps rely on Databases, and Cloud-based DBaaS services provide users with a Flexible, Scalable, and On-demand Platform that eliminates the need to set up costly physical hardware. MongoDB Atlas is a fully Cloud-based Database Service that hosts your data on MongoDB Instances. On the other hand, the Node.js driver provides an interface for connecting to and communicating with MongoDB Instances. 

Upon a complete walkthrough of this article, you will gain a holistic understanding of MongoDB Atlas and Node JS. This article will also provide you with a step-by-step guide on how to connect to MongoDB Atlas from a Node JS application and set up MongoDB Atlas Nodejs Integration.


  • An active MongoDB Atlas account.

How to Build the MongoDB Atlas Nodejs Integration?

Building the MongoDB Atlas Nodejs Integration is a fairly easy process. Follow the given three steps to set up MongoDB Atlas Nodejs Integration:

Step 1: Create a MongoDB Atlas Cluster

The first step involved in building the MongoDB Atlas Nodejs Integration requires you to create a new cluster. Follow the steps given below to do so:

  • Log in to your MongoDB Atlas account using the appropriate credentials. If you have never created a Cluster, you will encounter a screen like this:
MongoDB Atlas NodeJS - Creating a Cluster
Image Source
  • Click on the green-colored Build a Cluster button to create a new cluster. Upon clicking, you need to select the Cloud Provider and Region. You can proceed by leaving other settings to their default state.
MongoDB Atlas NodeJS- Selecting Cloud Provider & Region
Image Source
  • Once you have selected the Cloud Provider and Region, MongoDB Atlas will take around 5-10 minutes to configure and create a new cluster.

Step 2: Add User and Whitelist IP address

Once you have successfully created a cluster, it’s time to add a Database User and IP address of your current machine. Follow the steps given below to do so:

  • Navigate to the Database Access option and click on Add New Database User.
  • Fill in the Username and Password fields.
  • The next step is to Whitelist your IP address so that your machine can be recognized for regular access. To Whitelist an IP address, navigate to the Network Access option and click on Add IP Address.
  • Now, click on Allow Access from Anywhere which sets the IP address to global access.
MongoDB Atlas NodeJS - Allowing Access
Image Source

Step 3: Connect to your Database

  • Head back to the home page of MongoDB Atlas and select the Clusters option.
  • Now, click on the Connect Your Application option to set up a connection between your application and cluster using MongoDB’s native drivers.
  • Select Node.js as the native driver and save the Connection String provided by MongoDB Atlas for further reference.
MongoDB Atlas Nodejs Integration
Image Source
  • It’s now time to use Mongoose to create your database connection. Install Mongoose in your project by using the npm install mongoose command. Copy and paste the code below into db.js.

const mongoose = require('mongoose')

const url = `Connection String`;

const connectionParams={
    useNewUrlParser: true,
    useCreateIndex: true,
    useUnifiedTopology: true 
    .then( () => {
        console.log('Connected to the database ')
    .catch( (err) => {
        console.error(`Error connecting to the database. n${err}`);
  • Replace password with your own password and dbname with the name that you would like to give to your database. Once you have successfully executed the above code, you will see a Connected to the Database message on your console.

Once you have followed all the above steps in the correct sequence, you will be able to set up MongoDB Atlas Nodejs Integration in no time.

Simplify MongoDB ETL Using Hevo’s No-code Data Pipeline

Hevo is the only real-time ELT No-code Data Pipeline platform that cost-effectively automates data pipelines that are flexible to your needs. With integration with 150+ Data Sources (40+ free sources), we help you not only export data from sources & load data to the destinations but also transform & enrich your data, & make it analysis-ready.

Start for free now!

Get Started with Hevo for Free


This article introduced you the steps required to set up MongoDB Atlas Nodejs Integration. As your business begins to grow, data is generated at an exponential rate across all of your company’s SaaS applications, Databases, and other sources. To meet this growing storage and computing needs of data,  you would require to invest a portion of your engineering bandwidth to Integrate data from all sources, Clean & Transform it, and finally load it to a Cloud Data Warehouse for further Business Analytics. All of these challenges can be efficiently handled by a Cloud-Based ETL tool such as HevoData.

Visit our Website to Explore Hevo

Hevo Data, a No-code Data Pipeline provides you with a consistent and reliable solution to manage data transfer between a variety of sources like MongoDB and a wide variety of Desired Destinations, with a few clicks. Hevo Data with its strong integration with 150+ Data sources (including 40+ free sources) allows you to not only export data from your desired data sources & load it to the destination of your choice, but also transform & enrich your data to make it analysis-ready so that you can focus on your key business needs and perform insightful analysis using BI tools.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable Hevo Pricing that will help you choose the right plan for your business needs.

Share with us your experience of building MongoDB Atlas Nodejs Integration in the comments below!

Former Research Analyst, Hevo Data

Rakesh is a research analyst at Hevo Data with more than three years of experience in the field. He specializes in technologies, including API integration and machine learning. The combination of technical skills and a flair for writing brought him to the field of writing on highly complex topics. He has written numerous articles on a variety of data engineering topics, such as data integration, data analytics, and data management. He enjoys simplifying difficult subjects to help data practitioners with their doubts related to data engineering.

No Code Data Pipeline For MongoDB