Invalid mongodb uri - Apis and microservices

I’m working on URL Shortener for the APIs and Microservices projects, my connection string get’s an error on glitch saying “Invalid mongodb uri” but works fine on vscode and able to connect to MongoDB Atlas.

Here’s my connection string: mongodb+srv://fccstudent:<my password here>@apis-and-microservices-qwpty.mongodb.net/apis-and-microservices?retryWrites=true

The error says: Must begin with “mongodb://” How do i solve this?

Hello,
I’m working on the same project and I had the same message on VS Code. Solved it by updating Mongoose and MongoDB driver to the latest version on the package.json. I cloned the project from GitHub. You can update the package.json by updating each dependency. e.g.:

$npm install mongodb@^3.0.0 --save

This is will save the latest version of MongoDB driver to your package.json.

I checked the cloned copy of the project in glitch and it looks like the dependencies are 1 version behind. If you update that, it should fix it.

Good luck,

Phoebe.

3 Likes

From the Mongoose docs:

Note that Mongoose 5.x dropped support for all versions of MongoDB before 3.0.0. If you need to use MongoDB 2.6 or older, use Mongoose 4.x.

https://mongoosejs.com/docs/compatibility.html

1 Like

@willjw3 and @asianvader Thanks a lot!

1 Like

Just Use

npm i mongoose@5.7.0

See Mongoose support for all versions of MongoDB:- https://mongoosejs.com/docs/compatibility.html

2 Likes

Thanks, saved my day.