"Can't start redis server" exception occurs when trying to run Spring Boot on my MacBook M1 (Sonoma 14.0) – Redis

by
Ali Hasan
intellij-idea redis runtimeexception spring-boot

The Problem:

"Can’t start redis server" exception is encountered while attempting to run a Spring Boot application on a MacBook M1.

The Solutions:

Solution 1: Use a different and upgraded repo for Redis embedded server

When trying to run a Spring Boot application on a MacBook M1 with the Sonoma operating system (v14.x), an exception "Can’t start redis server. Check logs for details. Redis process log:" may occur. This is a common issue as reported on GitHub.

To resolve this problem, use a different and upgraded repository for the Redis embedded server in your application. One option is to use com.github.codemonstur:embedded-redis:1.0.0. This repository provides an updated version of the embedded Redis server that is compatible with the Sonoma operating system.

Here’s how you can add the new dependency to your project’s pom.xml file:

<dependency>
    <groupId>com.github.codemonstur</groupId>
    <artifactId>embedded-redis</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

This will replace the previous dependency on the Redis embedded server and should resolve the issue when running your Spring Boot application on MacOS Sonoma.

Solution 2: Configure application.yml file

The solution to the problem is to ensure that the application.yml file is properly configured to connect to the Redis server.

Specifically, you need to provide the following information:

  • Host: The IP address or hostname of the Redis server.
  • Port: The port that the Redis server is listening on.
  • Password: (Optional) The password required to connect to the Redis server.
  • Database: (Optional) The Redis database to use.
  • Timeout: (Optional) The maximum amount of time to wait for a connection to the Redis server.

Here is an example of a properly configured application.yml file:

spring:
  redis:
    host: 192.168.150.123
    port: 6379
    password: abcdef
    database: 2
    timeout: 30000ms
    lettuce:
      pool:
        max-active: -1
        max-idle: 500

Once you have made these changes, you should be able to start your Spring Boot application without encountering the “Can’t start redis server” exception.

Q&A

Why can’t I connect to Redis from my Spring Boot app?

Check that you have configured the application.yml file to load your Redis server’s host, port, and password.

What is causing "Can’t start redis server " exception?

Try using a different and upgraded repo for Redis embedded server like com.github.codemonstur: embedded-redis.