Jedis access to redis denied

CentOS7.0 installed redis4.0.10, successfully and connected successfully with RedisDesktopManager on windows.

CentOS Firewall is off:

clipboard.png

redis.conf:

clipboard.png

the java program is as follows:

public static void main(String[] args) {
    Jedis jedis = new Jedis("127.0.0.1",6379);
    System.out.println(jedis.get("name"));
}

the error is as follows:

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
    at redis.clients.jedis.Connection.connect(Connection.java:207)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:117)
    at redis.clients.jedis.Jedis.get(Jedis.java:152)
    at cn.chao.JedisTest.main(JedisTest.java:15)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)


what should I do?

Mar.20,2021

you need to make sure that your service is actually running

    ps -ef | grep redis
    netstat -antp | grep 6379
    

your java program runs on the same machine as redis?

Menu