Can't connect to mongoDB with replit

PLeeeeeeease help, URI is malformed.
I have whitelisted all IP’s and given the user read and write access. I have also tried using a newer version of mongoose in package.json. I have tried the mongo connection uri with and without database names that do and don’t exist yet.
I am dyyyyyiiiiinnnnnggg

Did you follow this startup guide (which is linked in the challenge description)?

Also, if your username/password contains any special characters they may need to be percent encoded:

1 Like

Yes I did all the steps (:

Can you show me your URI, with the username and password redacted? I guess it’s stored in your Secrets tab in replit?

I solved it, thank you so much.
It turns out the original password I had made had a bunch of special characters. I guess these were not translated properly when being used in replit.

Hi I have same problem. .here are my error message in the replit terminal

Your app is listening on port 3000
(node:10602) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist:
    at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/connection.js:847:32)
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:351:10
    at /home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:1149:10)
    at Mongoose.connect (/home/runner/boilerplate-mongomongoose/node_modules/mongoose/lib/index.js:350:20)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/myApp.js:4:10)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/home/runner/boilerplate-mongomongoose/server.js:67:16)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10602) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see (rejection id: 1)
(node:10602) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Did you allow access from all IP addresses when you set up your database connection?
The guide linked in the challenge description explains how to set this up correctly:

Ahh yes I have done it already and follow the guide. .I switch from replit to glitch and it solve my issues.

For those who got the message:

“One common reason is that you’re trying to access the database from an IP that isn’t whitelisted. Make sure your current IP address is on your Atlas cluster’s IP whitelist …”

Please visit your mongoDB homepage, look for “Network Access” in the “SECURITY” section, in the sidebar.

In the “Actions” column, go to “EDIT” and choose “ALLOW ACCESS FROM ANYWHERE”. The status will change to “pending”.
After the status changes to “active”, you can try to run your code in Replit.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.