Getting mongo connection error- Advanced Node and Express - Implement the Serialization of a Passport User

Tell us what’s happening:

I’ve set up a .env file and have added code in my server.js file to pass this task yet I’m getting a connection error from mongo.
The DB is set and ready to go in mLab, it has a user (listed as a db owner) and I’ve checked the username + password are correct in the string declared over at the .evn file, but I still can’t seem to get past this.

Has anyone stumbled upon a similar error?
Log text is as such: Database error: MongoParseError: URI malformed, cannot be parsed

Your code so far

'use strict';

const express     = require('express');
const bodyParser  = require('body-parser');
const fccTesting  = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const { MongoClient, ObjectID } = require('mongodb');

const app = express();

fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.urlencoded({ extended: true }));

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,

MongoClient.connect(process.env.DATABASE, (err, connection) => {
  if(err) {
    console.log('Database error: ' + err);
  } else {
    const db = connection.db();
    console.log('Successful database connection');
    passport.serializeUser((user, done) => {
      done(null, user._id);
    passport.deserializeUser((id, done) => {
        {_id: new ObjectID(id)},
          (err, doc) => {
            done(null, doc);
  app.listen(process.env.PORT || 3000, () => {
  console.log("Listening on port " + process.env.PORT);

  .get((req, res) => {
    res.sendFile(process.cwd() + '/views/index.html');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36.

Challenge: undefined

Link to the challenge:

Try printing out process.env.DATABASE to the console. If it’s ‘undefined’, try giving in the DB-URI as a direct string into MongoClient.connect. This will mostly solve the issue.