Redis Remote connection Timeout

Source: Internet
Author: User
Tags redis iptables redis server


When connecting to a remote Redis with Jedis today, throw the connection Timeout exception: Connect timed out. The specific information is as follows:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException:java.net.SocketTimeoutException : Connect timed out in Redis.clients.jedis.Connection.connect (connection.java:142) at Redis.clients.jedis.BinaryClient.connect (binaryclient.java:75) at Redis.clients.jedis.Connection.sendCommand ( connection.java:83) at Redis.clients.jedis.BinaryClient.set (binaryclient.java:92) at Redis.clients.jedis.Client.set (client.java:23) at Redis.clients.jedis.Jedis.set (jedis.java:53) at Com.ado.test.redis.RedisTest.main (redistest.java:10) caused by:java.net.SocketTimeoutException:connect timed out at Java.net.PlainSocketImpl.socketConnect (Native method) at Java.net.PlainSocketImpl.doConnect (Plainsocketimpl.java : 351) at Java.net.PlainSocketImpl.connectToAddress (plainsocketimpl.java:213) at Java.net.PlainSocketImpl.connect ( plainsocketimpl.java:200) at Java.net.SocksSocketImpl.connect (sockssocketimpl.java:366) at Java.net.Socket.connect (socket.java:529) at REDIS.CLIENTS.JEdis. Connection.connect (connection.java:137) ... 6 more

After confirmation, there are several possible exclusions:

1, server address configuration error. (confirmed, configured correctly.) )

2, the number of Redis connection is too high. (confirmed, there are no connections on the Redis server.) )

View Jedis connection source, also did not find anything unusual, so suspected is Redis host problem. Using the Telnet command for testing, the discovery is not connected. So the suspect is Redis server firewall is not shut down.

To view server firewall status:

Service Iptables Status


To turn off the firewall:

Service Iptables Stop


Then the connection was made, and this time the connection was successful. Solve the problem.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.