MongoDB Atlas authentication failed on Python

pymongo.errors.operationfailure: authentication failed.
mongodb atlas connection timeout
failed to connect to server mongodb atlas
bad auth authentication failed mongodb atlas
mongodb atlas troubleshooting
not connecting to mongodb atlas
mongodb authenticationfailed bad auth authentication failed
mongodb atlas max connections

I have deployed this Python app on Heroku and i want it to connect to a MongoDB Atlas cluster. I used my string to connect to the cluster, but for some reason i keep getting raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: bad auth Authentication failed. I checked twice and both the user and the password are correct. Any idea on why this is happening?

from pymongo import MongoClient
import time
import random
import time
import datetime


client = MongoClient('mongodb+srv://USER:<MYPASSWORD>@test-2liju.mongodb.net/test?retryWrites=true')

db = client.one

mycol = client["tst"]


while True:


    test = int(random.randrange(-99999990,90000000,1))

    dic = {"num": test}

    result = db.tst.insert_one(dic)


    print(test)
    time.sleep(5)

Stupid error, i had to type MYPASSWORD instead of <MYPASSWORD>, without the <>

Troubleshoot Connection Issues — MongoDB Atlas, Authentication to the cluster failed�. To connect to Atlas, you must authenticate with a MongoDB database user. To create a database user for your cluster, see� Authentication to the cluster failed¶ To connect to Atlas, you must authenticate with a MongoDB database user. To create a database user for your cluster, see Configure Database Users .

Don't use any special char in password, like '+' or '='.

I use OpenSSL to generate a password like u4wY9AOwnOLMY+h9EQ==. Came across bad auth Authentication failed.

After using MongoDB Compass it told me don't use special char, so I remove those and use like 'u4wY9AOwnOLMYh9EQ'.

Then it works.

Connect via Driver — MongoDB Atlas, To connect to an Atlas M0 (Free Tier) cluster, you must use Python 2.7.9+ and use a Without installed CA certificates, connections to Atlas will fail certificate� These examples cover all authentication methods currently supported by PyMongo, documenting Python module and MongoDB version dependencies. Percent-Escaping Username and Password ¶ Username and password must be percent-escaped with urllib.parse.quote_plus() in Python 3, or urllib.quote_plus() in Python 2, to be used in a MongoDB URI.

check the compatibility of the version of the Python driver you choose from the Mongodb Atlas Connections. versions above 3.4 are not supported by mongoengine flask

MongoDB Atlas authentication failed on Python, MongoDB Atlas authentication failed on Python - python. to a file, I can run other command in python using pymongo like: import json, os # load mongo library� To connect to an Atlas M0 (Free Tier) cluster, you must use Python 2.7.9+ and use a Python driver version that supports MongoDB 3.6. For complete documentation on compatibility between the Python driver and MongoDB, see the MongoDB compatibility matrix.

MongoDB Atlas authentication failed on Python, though ensured , MongoDB Atlas authentication failed on Python, though ensured Username & password are correct w/o any special characters. 93 Views. 0. MongoDB Atlas is the global cloud database service for modern applications. Deploy fully managed MongoDB across AWS, Azure, or GCP. Best-in-class automation and proven practices guarantee availability, scalability, and compliance with the most demanding data security and privacy standards.

Unable to connect to MongoDB Atlas Cluster � Issue #9867 , I am unable to connect Metabase to my MongoDB Atlas 4.0 database. It seems like several My authentication database is set to admin . My connection It seems that no matter what I do, I get the following connection error: Note. By default, MongoDB Atlas clusters do not need to be able to initiate connections to your application environments. If you wish to enable Atlas clusters with LDAP authentication and authorization, you must allow network access from Atlas clusters directly to your secure LDAP.

MongoDB Atlas - Can't connect to specific database, i'm getting this error : cmd failed: Authentication failed. You should be able to connect via mongoengine to MongoDB Atlas using MongoDB� If you are connecting to an Atlas cluster, first follow the procedure described in the Connect via Compass page in the Atlas documentation. The steps on that page will help ensure that your connection settings are optimized for Atlas. MongoDB Server Moved or Shutdown