Node.js app is working locally but doesn't seem to be connecting to the MongoDB database via Heroku

Hi All,

I am new to working on the back end of a website and have written the below code. It runs locally but the connection isn’t made when I host the back end code on Heroku. It seems that a connection isn’t even being made to MongoDB. Perhaps someone has some insight because I am very lost.

const mongoose = require("mongoose");

async function dbConnect() {
  // use mongoose to connect this app to our database on mongoDB using the DB_URL (connection string)
        //   these are options to ensure that the connection is done properly
        useNewUrlParser: true,
        useUnifiedTopology: true
    .then(() => {
      console.log("Successfully connected to MongoDB Atlas!");
    .catch((error) => {
      console.log("Unable to connect to MongoDB Atlas!");

module.exports = dbConnect;

Ive not used it myself…but i found this which indicated a number of steps needed…