Redis remote connection timeout

Source: Internet
Author: User
Zookeeper

When you connect to a remote redis instance using Jedis today, a connection timeout exception is thrown: connect timed out. The details are as follows:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed outat 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 outat 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

Several possibilities have been ruled out after confirmation:

1. The server address is incorrectly configured. (The configuration is correct after confirmation .)

2. There are too many redis connections. (It has been confirmed that there is no connection to the redis server .)

Check the Jedis Connection source code, and no exception is found, so it is suspected that it is a problem with the redis host. Use the Telnet command to test the connection. It is suspected that the redis server firewall is not closed.

View the Server Firewall Status:

services iptables status


Disable Firewall:

services iptables stop


Then connect, and the connection will soon be successful. Solve the problem.


Redis remote connection timeout

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.