pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

/home/mac126/.pyenv/versions/3.6.6/bin/python /home/mac126/Desktop/11/day1/mongo_cache.py
Traceback (most recent call last):
  File "/home/mac126/Desktop/11/day1/mongo_cache.py", line 47, in <module>
    mongo_cache = MongoCache()
  File "/home/mac126/Desktop/11/day1/mongo_cache.py", line 17, in __init__
    self.db.webpage.create_index(‘timestamp‘,expireAfterSeconds=expires.total_seconds())
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 1958, in create_index
    self.__create_index(keys, kwargs, session, **cmd_options)
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 1847, in __create_index
    with self._socket_for_writes() as sock_info:
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 196, in _socket_for_writes
    return self.__database.client._socket_for_writes()
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1085, in _socket_for_writes
    server = self._get_topology().select_server(writable_server_selector)
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 224, in select_server
    address))
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 183, in select_servers
    selector, server_timeout, address)
  File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 199, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

Process finished with exit code 1

看到一片飘红,有种无力的感觉,其实解决问题很简单,就是要有耐心一个一个去解决,先看一下报的什么错误,去百度一下,尝试自己解决问题,不能动不动就去问别人,问别人有的时候别人还很不耐烦,作为一名程序员,最重要的是解决问题的能力,废话不多说开始解决问题:

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

这个错误说明你的数据库可能没开,打开一下你的数据库就好了。

cd /usr/local/mongoDB/mongodbserver/bin#切换到你的mongodb/bin目录下
输入:
./mongod --dbpath ./

#启动程序

是不是很简单?留下你的答案让我们一起学习!

原文地址:https://www.cnblogs.com/liangliangzz/p/10158627.html

时间: 2024-10-31 19:40:29

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused的相关文章

connect() failed (111: Connection refused) while connecting to upstream

配置好lamp后,在浏览器中运行程序后,出现上面的错误. 转自:http://www.xuejiehome.com/blread-1828.html I'm experiencing 502 gateway errors when accessing a PHP file in a directory (http://domain.com/dev/index.php), the logs simply says this: 2011/09/30 23:47:54 [error] 31160#0:

监听状态显示: &nbsp; Linux Error: 111: Connection refused

现象:查看侦听状态时显示连接拒绝连接的提示. [[email protected] ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-OCT-2015 21:48:08 Copyright (c) 1991, 2009, Oracle.  All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) T

nginx connect() failed (111: Connection refused) while connecting to upstream,请求无响应错误

2015/01/02 16:01:36 [error] 29002#0: *714153 connect() failed (111: Connection refused) while connecting to upstream, client: 172.16.3.32, server: bizorder.qianbao666.com, request: "POST /api/queryOrder/orderList HTTP/1.1", upstream: "http:

Celery 提示[ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 61] Connection refused.

[2015-12-27 13:59:14,206: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 61] Connection refused.Trying again in 2.00 seconds... [2015-12-27 13:59:16,222: ERROR/MainProcess] consumer: Cannot connect to amqp://g

问题:connect() failed (111: Connection refused) while connecting to upstream

问题描述: 服务器重启之后,服务器也正常运行,发现网站访问不了,后来查看nginx 错误日志(/var/log/nginx/error.log ) 2016/05/13 10:47:32 [error] 7688#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: ****.****.****.33, server: , request: "GET url HTTP/1.1&

WARNING OGG-01223 TCP/IP error 111 (Connection refused)

一:问题描述 GGSCI (source_pc) 64> info all Program     Status      Group       Lag at Chkpt  Time Since Chkpt MANAGER     RUNNING                                           EXTRACT     RUNNING     EORA_T1     00:00:00      00:00:06    EXTRACT     ABENDED  

如何解决远程连接mysql出现Can’t connect to MySQL server on (111 “Connection refused”)的问题

如何解决远程连接mysql出现Can't connect to MySQL server on (111 "Connection refused")的问题 开放Mysql的远程连接 在服务器上登录mysql,然后执行以下的命令. 登录mysql: /usr/local/mysql-5.6/bin/mysql -u root -p 执行赋权的命令: MySQL> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '1234

mariadb报:ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/lib/mysql/mysql.sock&#39; (111 &quot;Connection refused&quot;)

我这边移除了mysql.sock文件后,重启服务就成功了. 还有一种情况,就是加入galera后,可能是server.cnf配置信息出了问题导致的,修改后,重新运行galera即可,数据库就可以启动成功了. mariadb报:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused") 原文地址:h

nginx和php-fpm配置 错误connect() failed (111: Connection refused) while connecting to upstream connect() to unix:/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream

若fpm配置文件中配置如下: listen = 127.0.0.1:9000 则对应的nginx.conf中的配置应为: fastcgi_pass 127.0.0.1:9000; 此时开启9000端口监听,不会生成sock文件 若fpm中的配置为使用Unix套接字,如下: listen = /run/php/php7.2-fpm.sock 则对应nginx.conf中的配置应为: fastcgi_pass unix:/run/php/php7.2-fpm.sock; 此时9000端口未开启,在/