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

问题描述:

我按照说明安装resque,但现在当我尝试生成一个工人用这个命令我得到一个连接错误:救援:连接被拒绝 - 无法连接到Redis的在localhost:6379

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

这是我得到的错误:

Connection refused - Unable to connect to Redis on localhost:6379

+0

看起来像redis服务器没有运行 – marcgg 2012-01-12 15:06:03

你安装了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 
    

您是否已经验证Redis的服务器正在运行?请不要问我解剖下面的命令,但在终端,你可以输入:

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服务器进程并将其从终端中分离出来。否则,我相信您需要在您希望redis服务器运行的整个时间内打开该终端。

(总是一个好主意,以验证正在运行的进程,一旦你火起来,因此请使用第一个命令一次)

更新:我不知道这是否适用于所有版本,但Ubuntu 16.04上的Redis Server 3.0.6,您也可以发布sudo service redis-server status。你会收到一些详细的输出,所以我不会发布一切,但这可能是我们一些人的另一种选择。

您应该使用redis端口来代替“localhost”。 因此,无论您想要连接redis,请使用“127.0.0.1”。

只是做: - sudo apt-get install redis-server

使用redis-server启动服务器,然后使用redis-cli ping以测试服务器已启动。如果服务器启动,您应该收到一个乒乓球。这是从文档中直接获取的。enter link description here