$ pip install redis
>>> import redis
>>> conn = redis.Redis()
>>> conn.keys('*')
Traceback (most recent call last):
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 484, in connect
sock = self._connect()
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 541, in _connect
raise err
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 529, in _connect
sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/henry/.local/lib/python3.5/site-packages/redis/client.py", line 667, in execute_command
connection.send_command(*args)
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 585, in send_packed_command
self.connect()
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 489, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 484, in connect
sock = self._connect()
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 541, in _connect
raise err
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 529, in _connect
sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/henry/.local/lib/python3.5/site-packages/redis/client.py", line 1032, in keys
return self.execute_command('KEYS', pattern)
File "/home/henry/.local/lib/python3.5/site-packages/redis/client.py", line 673, in execute_command
connection.send_command(*args)
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 585, in send_packed_command
self.connect()
File "/home/henry/.local/lib/python3.5/site-packages/redis/connection.py", line 489, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
上面是错误代码,出现这样的错误,解决方案:

这个问题是因为没安装Redis服务器造成的。

要么是安装一个redis,或者是启动redis。

redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.的更多相关文章

  1. redis.exceptions.ConnectionError: Error 10061 connecting to 127.0.0.1:6379. 由于目标计算机积极拒绝,无法连接

    redis.exceptions.ConnectionError: Error 10061 connecting to 127.0.0.1:6379. 由于目标计算机积极拒绝,无法连接   是由于没有 ...

  2. [Redis-CentOS7]Redis打开远程连接(十) Could not connect to Redis at 127.0.0.1:6379: Connection refused

    通过网络无法访问Redis redis-cli 172.16.1.111 Could not connect to Redis at 127.0.0.1:6379: Connection refuse ...

  3. Redis 服务端配置——Could not connect to Redis at 127.0.0.1:6379: Connection refused

    [root@centoszang 桌面]# redis-cli Could : Connection refused Could : Connection refused not connected& ...

  4. Could not connect to Redis at xxx.xxx.xxx.xxx:6379: Connection refused

    开发发来消息说测试环境的redis无法登录: # redis-cli -p 6379 -h xxx.xxx.xxx.xxx Could not connect to Redis at xxx.xxx. ...

  5. 在 Linux redis 验证交互连接过程中遇到 redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 的解决方法

    Could not connect to Redis at 127.0.0.1:6379: Connection refused 1.找到redis.conf 并修改 daemonize no 为 d ...

  6. redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 问题解决

    1.启动redis 客户端 redis-cli 报错 redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 是因 ...

  7. Could not connect to Redis at 127.0.0.1:6379: Connection refused

    启动redis:  redis-server ../redis.conf redis启动成功后 执行命令行redis-cli报:Could not connect to Redis at 127.0. ...

  8. Redis配置主从时报错“Could not connect to Redis at 192.168.0.50:6379: Connection refused not connected>”

    配置Redis主从时,修改完从节点配置文件,然后报错 [root@Rich七哥-0-50 redis]# /opt/redis/redis-cli -h 192.168.0.50 Could not ...

  9. Could not connect to Redis at 192.168.0.129:6379: Connection refused

    在虚拟机上(CentOS 6.7)本机连接自己的redis [root@localhost bin]# ./redis-cli -h Could not connect to Redis at : C ...

随机推荐

  1. cve-2018-4878漏洞复现

    CVE-2018-4878Flash 0day漏洞1.漏洞概述2018年2月1号,Adobe官方发布安全通报(APSA18-01),声明Adobe Flash 28.0.0.137及其之前的版本,存在 ...

  2. WinForm控件Dock属性设置会遮盖其他控件的解决

    在被遮盖住的控件上,右击弹出快捷菜单,然后选择“置于顶层”.

  3. mysql_主从同步

    在这里我就不说怎么搭建 Mysql 数据库了!如果有需要可以参照我前面的博文. 此博文主要说配置 Linux  数据库   主从   下面我们开始进入正题. master:192.168.31.200 ...

  4. Java多线中基础知识整理

    Java多线程中相关术语: 一.Java多线程原则 1.原子性:一个操作或者多个操作要么全部执行并且执行的过程不会被任何因素打断,要么就都不执行.一般使用线程同步或者Lock锁来确保. 2.可见性(J ...

  5. (Linux)CentOS7下安装JDK 1.8

    参考:http://www.cnblogs.com/sxdcgaq8080/p/7492426.html 1.首先查看CentOS7是否有自带的JDK ,一般Linux会自动下载安装Open JDK ...

  6. C# Asp.net中简单操作MongoDB数据库(一)

    需要引用MongoDB.Driver.dll.MongoDB.Driver.core.dll.MongoDB.Bson.dll三个dll. 1.数据库连接: public class MongoDb ...

  7. leetcode 之 two sum (easy)c++

    1.数组的长度 length() .容器vector长度  size() .容器vector vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库. ...

  8. docker命令汇总

    docker命令汇总 序号 类别 简述 命令 功能 说明 1 整体管理 安装 yum install docker-engine centos上安装docker Ubuntu上安装dockerapt- ...

  9. JAVA学习笔记 (okHttp3的用法)

    最近的项目中有个接口是返回文件流数据,根据我们这边一个验签的插件,我发现里面有okHttpClient提供了Call.Factory,所以就学习了下okHttp3的用法. 1.概述 okhttp是一个 ...

  10. 2018-2019-2 《网络对抗技术》Kali安装 Week1 20165236

    2018-2019-2 <网络对抗技术>Kali安装 Week1 20165236 一.kali 下载 安装 网络 共享 软件源 二.安装步骤 1.官网上下载kali Linux: 2.参 ...