java.net.SocketTimeoutException: connect timed out

831 views
Skip to first unread message

amala

unread,
Nov 9, 2011, 10:57:37 PM11/9/11
to Jedis
I'm using jedis for simple key-value data store...

private static final String HOST = "50.30.35.9";
private static final int PORT = 2863;
Jedis jedis = new Jedis(HOST);

try {
jedis.set("foo", "bar");
jedis.get("foo");
} catch (Exception e) {
System.err.println("Unable to connect to Redis");
e.printStackTrace();
}

When i test redis server with jedis client, i got the following
exception

redis.clients.jedis.exceptions.JedisConnectionException:
java.net.SocketTimeoutException: connect timed out
at redis.clients.jedis.Connection.connect(Connection.java:124)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:
54)
at redis.clients.jedis.Connection.sendCommand(Connection.java:
77)
at redis.clients.jedis.BinaryClient.set(BinaryClient.java:71)
at redis.clients.jedis.Client.set(Client.java:21)
at redis.clients.jedis.Jedis.set(Jedis.java:48)

Jakub Białek

unread,
Nov 10, 2011, 1:18:36 AM11/10/11
to jedis...@googlegroups.com
If redis is on different port than default (6379)  you should use Jedis constructor with host and port parameters.

Best regards,
Ragnor

amala

unread,
Nov 10, 2011, 2:15:21 AM11/10/11
to Jedis
Thanks for quick response. If i pass host and port parameters

jedis = new Jedis(HOST, PORT);

I'm getting following exception

redis.clients.jedis.exceptions.JedisConnectionException:
java.net.ConnectExcepti
on: Connection refused: connect
at redis.clients.jedis.Connection.connect(Connection.java:124)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:
54)
at redis.clients.jedis.Connection.sendCommand(Connection.java:
77)
at redis.clients.jedis.BinaryClient.set(BinaryClient.java:71)
at redis.clients.jedis.Client.set(Client.java:21)
at redis.clients.jedis.Jedis.set(Jedis.java:48)

On Nov 10, 11:18 am, Jakub Białek <ragno...@gmail.com> wrote:
> If redis is on different port than default (6379)  you should use Jedis
> constructor with host and port parameters.
>
> Best regards,
> Ragnor
>

amala

unread,
Nov 10, 2011, 3:11:04 AM11/10/11
to Jedis
I am unable to reach the Redis instance hosted by Redis4you even via
telnet, even though the Redis4you portal claims it is running. How do
I debug the root cause of this issue?

On Nov 10, 12:15 pm, amala <amala....@gmail.com> wrote:
> Thanks for quick response. If i pass host and port parameters
>
>                   jedis = new Jedis(HOST, PORT);
>
> I'm getting following exception
>
> redis.clients.jedis.exceptions.JedisConnectionException:
> java.net.ConnectExcepti
> on: Connection refused: connect
>         at redis.clients.jedis.Connection.connect(Connection.java:124)
>         at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:
> 54)
>         at redis.clients.jedis.Connection.sendCommand(Connection.java:
> 77)
>         at redis.clients.jedis.BinaryClient.set(BinaryClient.java:71)
>         at redis.clients.jedis.Client.set(Client.java:21)
>         at redis.clients.jedis.Jedis.set(Jedis.java:48)
>

Jonathan Leibiusky

unread,
Nov 10, 2011, 8:54:33 AM11/10/11
to jedis...@googlegroups.com
Well, if you can't even telnet to that instance it means either it is
not running or it is running but on a different port. You should
probably make sure it is running and you have the correct information.
I don't know how can we help more here.

--
Sent from my mobile device

amala

unread,
Nov 10, 2011, 10:39:01 PM11/10/11
to Jedis
Hi Jonathan, thanks for ur reply. I got connection from Redis TO GO.
    private static final String HOST = "tetra.redistogo.com";   
private static final int PORT = 9270;
Now its working for me.

On Nov 10, 6:54 pm, Jonathan Leibiusky <ionat...@gmail.com> wrote:
> Well, if you can't even telnet to that instance it means either it is
> not running or it is running but on a different port. You should
> probably make sure it is running and you have the correct information.
> I don't know how can we help more here.
>

Jonathan Leibiusky

unread,
Nov 11, 2011, 6:22:00 AM11/11/11
to jedis...@googlegroups.com
awesome! glad it is working!
Reply all
Reply to author
Forward
0 new messages