救援:连接被拒绝 - 无法连接到localhost:6379上的Redis

时间:2011-01-12 14:45:06

标签: redis resque

我已按照说明安装resque,但现在当我尝试使用此命令生成一个worker时,我收到连接错误:

$ QUEUE=mailer rake environment resque:work --trace

这是我得到的错误:

  

拒绝连接 - 无法连接到localhost上的Redis:6379

4 个答案:

答案 0 :(得分:54)

您确认redis-server正在运行吗?请不要让我剖析以下命令,但在终端中您可以输入:

ps aux | grep redis

然后您应该看到类似的内容:

redis 13319 0.0 0.0 2884 1056 ? Ss 10:54 0:00 /usr/bin/redis-server /etc/redis/redis.conf

如果它没有运行,我建议发出以下命令:

nohup redis-server &

这将启动redis-server进程并将其从终端分离。否则,我相信你需要在你希望redis-server运行的整个时间内打开终端。

(一旦启动它,一定要好好验证进程是否正在运行,所以再次使用第一个命令。)

更新:我不确定这是否适用于所有版本,但在Ubuntu 16.04上的Redis Server 3.0.6上,您也可以发布sudo service redis-server status。你会得到一些详细的输出,所以我不会发布所有内容,但这对我们中的某些人来说可能是另一种选择。

答案 1 :(得分:14)

你安装了redis吗?

在Ubuntu上安装REDIS

参考:http://redis.io/download

  1. 使用以下命令下载,解压缩和编译Redis:

    $ cd ~/Installations
    $ curl -O http://redis.googlecode.com/files/redis-2.2.1.tar.gz
    $ tar xzf redis-2.2.1.tar.gz
    $ cd redis-2.2.1
    $ sudo make
    
  2. 安装Tcl(工具命令语言)运行时

    $ sudo apt-get install tcl8.5
    
  3. 运行Redis服务器

    $ src/redis-server
    [31371] 24 Feb 10:14:03 # Warning: no config file specified, using the default config. In order to   specify a config file use 'redis-server /path/to/redis.conf'
    [31371] 24 Feb 10:14:03 * Server started, Redis version 2.2.1
    [31371] 24 Feb 10:14:03 # WARNING overcommit_memory is set to 0! Background save may  fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    [31371] 24 Feb 10:14:03 * The server is now ready to accept connections on port 6379
    

答案 2 :(得分:9)

就这样做: - sudo apt-get install redis-server

答案 3 :(得分:1)

您应该使用redis端口" localhost" 。 所以,无论你想在哪里连接redis,都要使用" 127.0.0.1"