This guide provides steps to diagnose and fix common issues when the Redis service fails to start on a Linux system using systemd
.
π Step 1: Check Redis Service Status
Start by checking the status of the Redis service:
sudo systemctl status redis-server
If the service failed to start, you will see output indicating an error. Example:
redis-server.service: Failed with result 'exit-code'.
π Step 2: View Detailed Logs with journalctl
To understand why Redis failed, use journalctl
to inspect logs:
sudo journalctl -u redis-server
This command shows the logs specific to the Redis service.
π Case 1: Missing Log File/Directory
Example error message from journalctl:
*** FATAL CONFIG FILE ERROR ***
Can't open the log file: No such file or directory
This gives you precise information about what caused the failure (e.g. missing log file, port in use, config syntax error, etc.).
If the error is related to missing log file or directory (as shown above), follow these steps:
sudo mkdir -p /var/log/redis
sudo chown redis:redis /var/log/redis
sudo chmod 755 /var/log/redis
sudo systemctl restart redis-server
π Case 2: Port Already in Use
Example error from journalctl:
Failed to bind to 127.0.0.1:6379: Address already in use
Cause: Another process is already using the Redis default port (6379).
Solution:
Check which process is using the port: sudo lsof -i :6379
If another process is occupying the port, either stop that process or change Redisβs port in the config file (/etc/redis/redis.conf):
Open the config file and find the line with port 6379: sudo nano /etc/redis/redis.conf
Change the port number, e.g., port 6380.
β Confirm Redis is Running
After resolving the issue, recheck the status:
sudo systemctl status redis-server
You should see:
Active: active (running)
π§ͺ Optional: View Redis Logs
After Redis starts successfully, you can review logs here (if enabled in your config):
cat /var/log/redis/redis-server.log