I was running into this problem too (on Repl.it). I don’t know exactly how to solve it “correctly”. But I had to change
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
to just
mongoose.connect(process.env.MONGO_URI);
Then I had to remove the quotes I placed around my MONGO_URI in my .env
file.
It gives a deprecation warning but at least it works, I guess… I couldn’t seem to find a solution using the new URL parser and proper quote formatting. If anyone knows and would like to share, that’d be cool.
Also if anyone is wondering like I was, for <dbname>
in your Mongo URI you can replace it with anything, or manually create a database & collection in your MongoDB account by hitting the “collections” button on the cluster overview page, and fill in <dbname>
with whatever you decide to name your database on the collections page.