Can’t start Redis from java application

I just pulled the project on my mac(Intel i9) from my work repository and tried to run integration tests but getting an error:

java.lang.RuntimeException: Can't start redis server. Check logs for details.

at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
at redis.embedded.RedisServer.start(RedisServer.java:9)

Redis 7.2.3 is installed. I can run it using the command redis-server or run it as a service using brew services start redis. Everything works as expected. I tried to connect using redis-cli and type ping and get pong as expected.

But the problem is that my Java project can’t run it. I tried to kill all related ports. give 777 mode to the Redis installation directory, and change the Redis port in the java application(i.e. use 6380 or 6381 instead of standard 6379). The project is using com.github.kstyrc:embedded-redis:0.6 library.

Here is code snipped how it starts redis

private static final int REDIS_PORT = 6379;
private static RedisServer redisServer;

public static void startEmbeddedRedis() {
    try {
        redisServer = new RedisServer(REDIS_PORT);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    redisServer.start();
    while (!redisServer.isActive()) {
        System.out.println("Await activation...");
    }
}

I also tried to debug the issue by deep diving into library classes but couldn’t find anything.
enter image description here

Any idea what else I need to check or missing?

  • Can you provide redis logs, as stated in the error stack trace Check logs for details. Maybe there is something relevant there.

    – 

  • I checked Redis logs those attempts(That I’ve tried from a Java application) are not reflected there. I think something is happening before it even reaches to the Redis itself

    – 

Leave a Comment