Jump to content

[Solved] MongoDB Atlas with python


mahbd

Recommended Posts

Hi,

I'm trying to run this script to check if MongoDB atlas is working with python. 

#!/usr/bin/python3.7

import pymongo

print("Content-Type: text/html\n\n")

mongoLink = "mongodb+srv://username:password@cluster0.wkb1y.mongodb.net/DjCh?retryWrites=true"
try:
    myClient = pymongo.MongoClient(mongoLink)
    print(myClient.list_database_names())
except Exception as e:
    print(str(e))

The above script is working fine on my local mechine. I also allowed access from anywhere(0.0.0.0/0). But I'm getting this error on http://mahbd.heliohost.org/cgi-bin/test.py .

cluster0-shard-00-02.wkb1y.mongodb.net:27017: [Errno 111] Connection refused,cluster0-shard-00-01.wkb1y.mongodb.net:27017: [Errno 111] Connection refused,cluster0-shard-00-00.wkb1y.mongodb.net:27017: [Errno 111] Connection refused

How can I solve this?

Link to comment
Share on other sites

The port 27017 is blocked in the firewall, but it can be opened for users who are not violating our terms of service.

 

Our systems detected that you might have more than one account.
 
We understand that no one ever reads our terms, but as a reminder, our Terms of Service state that each user is allowed to have only one account. The reason we have to enforce this rule is because our servers are already overloaded the way it is, and it wouldn't be fair to everyone that is turned away each day for you to have more than one when so many others have none.
 
One common reason people create more than one account is to get around our storage limit of 1000 MB. Did you know that we will give you another 1000 MB of storage for each $5 USD donation you make up to 5000 MB total? If you'd like to increase the storage of your account just make a donation and then let us know your transaction ID and username.
 
Another common reason people create more than one account is to host more than one website. Did you know that you can host as many websites on your one account as you want? Unlike a lot of free hosts we offer unlimited alias domains, unlimited addon domains, and unlimited subdomains. If you need any help adding another website to your account just let us know.
 
Another common reason people create more than one account is to try out several servers at once, or to transfer a website between accounts on different servers. Did you know that an admin can move your account for you for as little as a $1 USD donation? This will save you the trouble of signing up again, and deleting your account, etc.
 
Sometimes our systems flags you as possibly having more than one account when you share a computer with family, friends, coworkers, other students, etc. If this is your situation we apologize for the suspension, and we'll be happy to unsuspend all of the involved accounts after you provide proof that each of the accounts belong to a different person.

 

Please delete all accounts in excess of 1. Let us know when that is done and we can see about opening a port in the firewall for you.

  • Like 1
Link to comment
Share on other sites

After removing block this message was coming. 

No replica set members match selector "Primary()"

I thought this is my configuration problem. So, I tried all possible solution. But none of them worked. At last I came to this post. https://stackoverflow.com/questions/40765581/pymongo-read-preferences-serverselectiontimeouterror-no-primary-available-for .

According to the post replica set members uses its internal IP's. So, I guess unblocking only "34.202.76.163" causing this problem. Will you take a look.

Thanks in advance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...