nodejs-shopping-cart icon indicating copy to clipboard operation
nodejs-shopping-cart copied to clipboard

Can't connect to mongoDB

Open mylastore opened this issue 6 years ago • 1 comments

I am using mlab remote mongoDB and get this message added the connection uri to the .env. I have node v 7.2.1, npm 4.0.5

MongoError: failed to connect to server [undefined:27017] on first connect [MongoError: getaddrinfo ENOTFOUND undefined undefined:27017]

mylastore avatar Jul 22 '17 06:07 mylastore

@mylastore its because your process.env.MONGO_DB_URI is undefined.

Before "npm start" you need to manually export MONGO_DB_URI variable with:

export MONGO_DB_URI=your_remote_mlab_uri

You can also setup dotenv on project to user an .env file.

brenohq avatar Oct 17 '19 00:10 brenohq