Search code examples
javascriptnode.jsmongodbmongooseglitch-framework

Glitch - MongoError: failed to connect to server [undefined:27017]


I am going through FreeCodeCamp's curriculum. I am still a back end newbie.

I am currently in this project. In order do the project, we are supposed to "fork" it in Glitch or GitHub.

Start this project on Glitch using this link or clone this repository on GitHub! If you use Glitch, remember to save the link to your project somewhere safe!

However, as soon as I fork the project I am getting this error:

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

The only thing I touched is mongoose.connect in order to link my database.

mongoose.connect(process.env.MLAB_URI)

Thank you in advance!


Solution

  • Well... I am ashamed of answering my own question like this:

    People, don't forget the quotes (or double quotes) at the beginning and end of your database URI.

    Inside .env file ---> Variable Name = "Your URI"