37

I have followed the instructions to install resque, but now when I try to spawn a worker with this command I get a connection error:

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

this is the error that I get:

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

2
  • looks like the redis server isn't running
    – marcgg
    Commented Jan 12, 2012 at 15:06
  • Server Fault has a canonical question about Connection Refused.
    – Raedwald
    Commented Sep 30, 2015 at 12:37

6 Answers 6

55

Have you verified redis-server is running? Please don't ask me to dissect the following command, but in a terminal you can type:

ps aux | grep redis

You should then see something like:

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

If it's not running, I recommend issuing the following command:

nohup redis-server &

That will start a redis-server process and detach it from the terminal. Otherwise I believe you need to leave that terminal open the entire time you want redis-server to be running.

(Always a good idea to verify the process is running once you fire it up, so use that first command once more.)

Update: I'm not sure if this works for all versions, but on Redis Server 3.0.6 on Ubuntu 16.04, you can issue sudo service redis-server status as well. You'll receive some verbose output, so I'll not post it all, but that may be another option for some of us.

0
15

Have you installed redis?

Installing REDIS on Ubuntu

Ref: http://redis.io/download

  1. Download, extract and compile Redis with:-

    $ 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. Install Tcl (the Tool Command Language) runtime

    $ sudo apt-get install tcl8.5
    
  3. Running Redis Server

    $ 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
    
11

just do it:- sudo apt-get install redis-server

0
4

Use redis-server to Start the server and then use redis-cli ping to test if the server is up. You should receive a pong if the server is started. This was taken straight from the docs. enter link description here

2

You should use the "127.0.0.1:6379" instead "localhost:6379" for connecting to redis. so, wherever you want to connect the redis, use the redis-server ip.

2
  • It seems that the redis port has nothing to do with HTTP port. The 127.0.0.1 is HTTP localhost. Commented Apr 11, 2021 at 0:25
  • @YanKingYin localhost is a FQDN. On most computers, it translates to 127.0.0.1 in IPv4 or ::1 in IPv6. So, it's not related to HTTP or other protocols.
    – Reza-S4
    Commented Feb 6, 2023 at 17:15
0
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-redis</artifactId>
    <version>${spring-data-redis.version}</version>
</dependency>
<dependency>
    <groupId>io.lettuce</groupId>
    <artifactId>lettuce-core</artifactId>
    <version>${lettuce.version}</version>
</dependency>

If you use this old way to connect to Redis, try to set 'use-ssl=false' in your application.properties

redis.host=localhost
redis.port=6379
redis.use-ssl=false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.