[Solved] Jedis connect and operate Redis error: Failed to create socket和connect timed out

error messages:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
Exception in thread "main"redis.clients.jedis.exceptions.JedisConnectionException: Failed to create socket.
java.net.SocketTimeoutException: connect timed out

Reason: Unable to load class “org . slf4j . impl . staticloggerbinder”, no operation (NOP) logger implementation by default, cannot create socket, resulting in connection timeout.


Step 1: add import dependency first (because a class cannot be loaded, it means that there is no dependency in the library, so it needs to import dependency)

<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->

Step 2: Comment out bind on line 69 of the redis.conf configuration file. Commenting out bind means that all client access is available, which is equivalent to bind

Step 3: Change yes to no in protected-mode yes on line 88

Step 4: Kill the redis process and restart it
ps -ef |grep redis
kill the redis process port number
redis-server . /xiaoConfig/redis-conf
redis-cli -p 6379

Step 5: Connecting to Redis in idea by manipulating jedis
finally successful:

Read More: