Ask coding questions

← Back to all posts
Pymongodb errors
DwellerIgor (1)

hello. im trying to login into mongodb using python, but i get the error pymongo.errors.InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus()., but when i use urllib.parse.quote_plus() it gives me another error pymongo.errors.ConfigurationError: A password is required.. But the password is inside urllib.parse.quote_plus()! the bot doesn't see it i think. how to solve those errors? thank you!

Comments
hotnewtop
InvisibleOne (3206)

I don't use urllib.parse.quote_plus()
Just take the srv URL it generates and replace the username with the username, and the password with the password.
I've never had it ask me to use urllib.

DwellerIgor (1)

what do you mean replace username with username and password with password @InvisibleOne

InvisibleOne (3206)

I go to connect on my cluster, then connect to your application and it will give me a link like this:

mongodb+srv://<username>:<password>@cluster0.659m0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Then I replace <username> with the username and <password> with the password I created when I made under database access
@DwellerIgor

DwellerIgor (1)

im using the link and i changed everything for good, but it still says i need to use parse.quote_plus() to put password and username in there. but when i do that bot says pymongo.errors.ConfigurationError: A password is required. i changed password with password and username with username long time ago @InvisibleOne

InvisibleOne (3206)

Which password did you put in? The one that you use to sign in to mongodb online? or your database access password. @DwellerIgor

DwellerIgor (1)

that i use to sign in to mongodb online @InvisibleOne

InvisibleOne (3206)

that's wrong, you need to create a database access use under security on the left side of your database manager.
@DwellerIgor

DwellerIgor (1)

i still don't quite understand where to create the password. i went to database acces and created new password, but it still doesnt work. maybe i can have your discord, so i can send you some pictures? @InvisibleOne

DwellerIgor (1)

very useful. i used this step to create password 'Click the button to create a database user', right? but im still getting the error @InvisibleOne

InvisibleOne (3206)

Did you follow the steps? You should create a database user and then put that username and password into the URL. Also make sure that you added access under Network Security I believe it is.
I just set it to allow access from anywhere because the IP address for a repl can change. @DwellerIgor