【问题标题】:redis.exceptions.ConnectionError: Error 97 connecting to localhost:6379. Address family not supported by protocolredis.exceptions.ConnectionError:连接到 localhost:6379 时出现错误 97。协议不支持的地址族
【发布时间】:2017-01-20 15:56:03
【问题描述】:

当我尝试运行我的程序时,会出现以下错误。

redis.exceptions.ConnectionError:连接到 localhost:6379 时出现错误 97。协议不支持地址族。

之前程序运行正常,现在会报这个错误。

Traceback (most recent call last):
  File "securit.py", line 26, in <module>
    bank = red.get('bank')
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 880, in get
    return self.execute_command('GET', name)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 578, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 563, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 538, in send_packed_command
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 97 connecting to localhost:6379. Address family not supported by protocol.

【问题讨论】:

    标签: python django redis socket.io


    【解决方案1】:

    最后我得到了上述问题的答案。一步一步完成以下操作

     Setup
    
        Before you install redis, there are a couple of prerequisites that need to be downloaded to make the installation as easy as possible.
    
        Start off by updating all of the apt-get packages:
    
        **sudo apt-get update**
    
        Once the process finishes, download a compiler with build essential which will help us install Redis from source:
    
         **sudo apt-get install build-essential**
    
        Finally, we need to download tcl:
    
         **sudo apt-get install tcl8.5**
    
        Installing Redis
    
        With all of the prerequisites and dependencies downloaded to the server, we can go ahead and begin to install redis from source:
    
        Download the latest stable release tarball from Redis.io.
    
        **wget http://download.redis.io/releases/redis-stable.tar.gz**
    
        Untar it and switch into that directory:
    
        **tar xzf redis-stable.tar.gz**
    
        **cd redis-stable**
    
        Proceed to with the make command:
    
        **make**
    
        Run the recommended make test:
    
        **make test**
    
        Finish up by running make install, which installs the program system-wide.
    
        **sudo make install**
    
        Once the program has been installed, Redis comes with a built in script that sets up Redis to run as a background daemon.
    
        To access the script move into the utils directory:
    
        **cd utils**
    
        From there, run the Ubuntu/Debian install script:
    
        **sudo ./install_server.sh**
    
        As the script runs, you can choose the default options by pressing enter. Once the script completes, the redis-server will be running in the background.
    

    【讨论】:

      【解决方案2】:

      遇到了同样的问题。从 /etc/hosts 文件中删除 IPv6 地址对我有帮助

      【讨论】:

        猜你喜欢
        • 2021-09-19
        • 2013-02-04
        • 1970-01-01
        • 2012-12-03
        • 1970-01-01
        • 2013-12-20
        • 1970-01-01
        • 1970-01-01
        • 2014-09-30
        相关资源
        最近更新 更多