9

I'm trying the Jedis (Redis for Java) "Basic usage example" from https://github.com/xetorthio/jedis/wiki/Getting-started but I'm getting the following error:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:42)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused

I'm trying this on OSX 10.9.2 with Jedis-2.4.2, commons-pool2-2.0

Uwat
  • 246
  • 1
  • 2
  • 7

5 Answers5

11

Had the same trouble. All the tutorials online show just running some simple Java BUT you need to have the redis server running on your computer (duh...). As a noobie I thought it all came in the jar but it does not. It is a database just like Mongo or whatever. Try this:

redis download

After you download, unzip it into the UserApps folder (on windows) and then run redis-server.exe. A window will pop up with the port and such in it. Then run your java. Bam, works like a charm!

markthegrea
  • 3,731
  • 7
  • 55
  • 78
2

You will get this because either you don't have redis running or you're trying to connect to it on the wrong host/port.

tddmonkey
  • 20,798
  • 10
  • 58
  • 67
2

I just resolved this problem by downloading Redis setup from https://github.com/MSOpenTech/redis/releases and simply installing it. Its more simple and suggested on Redis Download page.

Latest stable release is 2.8.2104

Hafsa
  • 49
  • 4
1

The code works fine for me: Installing and starting the redis server at localhost:6379

  • Install
$ wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz 
$ tar xzf redis-2.2.12.tar.gz 
$ cd redis-2.2.12 
$ make
$ make install 
  • Start

$/usr/local/bin/redis-server

from http://reistiago.wordpress.com/2011/07/23/installing-on-redis-mac-os-x/

Umpa
  • 334
  • 11
  • 16
0

eh.this problem i had also came across. Because start the redis server on cmd and store some keys into it.and then i close the server and change to Eclipse tutorial about redis then get such exceptions. solutions: you can just go to the redis directory in CMD and input "redis-server.exe redis.conf" to start the server. then rerun your previous application in eclipse and it will be ok!

Crabime
  • 644
  • 11
  • 27