Node mongodb client not recognizing port

I have mongodb://localhost:27017 for the node.js mongodb 4.1.0 library. But it still insists on using port 5432 and I get ‘error fetching client from pool Error: connect ECONNREFUSED 127.0.0.1:5432’

Is this a bug?

function connect(dbURI) {
  console.log(dbURI);
  return MongoClient
    .connect(dbURI)
    .then(function(client) {
      const db = client.db('dolphin');

Most likely in your code.

How do you call your connect() function?

What is the parameter you use?

How is it initialized?

What is the output of the first console.log()?

    const MongoClient = require('mongodb').MongoClient;
    const TempUsers = require('./models/TempUsers');
    const colors = require('colors');

    const collections = {
      tempUsers: false
    };

    function connect(dbURI) {
      console.log(dbURI);
      return MongoClient
    .connect(dbURI)
    .then(function(client) {
      const db = client.db('dolphin');
      console.log(colors
        .bold('MongoDB default connection open to ' + dbURI));
      initDbListeners(client);
      initCollections(db);
      return client;
    })
    .catch(function(err) {
      console.log(colors
        .red(err));
    });
    }

const runDevelopmentMongo = () => {
  mongoDbUri = 'mongodb://localhost:27017';

  return mongo.connect(mongoDbUri)
    .then(function(db) {
      console.log(colors.magenta('Mongo server is running'));
      return db
    })
    .catch(function(err) {
      console.log(colors
        .red(`Mongo connection error: ${err}`));
    });
};

The output of the dbURI log is mongodb://localhost:27017

Sorry, please disregard. This error is actually coming from postgres and not mongodb.