Why is PyMongo 3 giving ServerSelectionTimeoutError?

后端 未结 20 955
我在风中等你
我在风中等你 2020-11-30 01:21

I\'m using:

  • Python 3.4.2
  • PyMongo 3.0.2
  • mongolab running mongod 2.6.9
  • uWSGI 2.0.10
  • CherryPy 3.7.0
  • nginx 1.6.2
相关标签:
20条回答
  • 2020-11-30 02:27

    I ran into the same issue during development. It was due to the fact that mongodb wasn't running on my local machine (sudo systemctl restart mongod to get mongodb running on Ubuntu).

    0 讨论(0)
  • 2020-11-30 02:28

    As mentioned here: https://stackoverflow.com/a/54314615/8953378

    I added ?ssl=true&ssl_cert_reqs=CERT_NONE to my connection string, and it fixed the issue.

    so instead of:

    connection_string = "mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>/<COLLECTION>"
    

    I wrote:

    connection_string = "mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>/<COLLECTION>?ssl=true&ssl_cert_reqs=CERT_NONE"
    

    (Note that if you have other parameters in your connection string, you need to change the ? to & )

    0 讨论(0)
提交回复
热议问题