Check that supervised in /etc/redis/redis.conf matches the unit. If the unit is Type=notify, the config must say supervised systemd. A mismatch makes systemd wait for a readiness signal that never arrives, then kill a Redis that was running perfectly well.
grep -E '^(supervised|daemonize)' /etc/redis/redis.conf systemctl show redis-server -p Type
This is the failure that wastes the most time, because Redis itself is fine. Start it by hand and it works; start it through systemd and it dies after the timeout. The two must agree.
The supervised and daemonize rules
Type=notifyin the unit requiressupervised systemdin the config. Without it, systemd waits for a notification Redis never sends, reports a timeout and kills the process.daemonize yeswithType=notifyorType=simpleis always wrong. Redis forks into the background, systemd loses track of the process it started, and treats the exit of the parent as a failure. Under systemd,daemonizeshould beno.- The Debian and Ubuntu packages already set this correctly. If you are hitting it, the config was almost certainly edited by a tutorial that assumed a manual build. Guides written for a source install routinely tell you to set
daemonize yes, which breaks the packaged unit.
The other causes worth checking
- Cannot open the log file. The journal shows
Can't open the log file: Permission denied. Redis runs as the redis user and needs ownership of its log and working directories:sudo chown -R redis:redis /var/log/redis /var/lib/redis sudo chmod 750 /var/lib/redis
status=226/NAMESPACE. This is a sandboxing failure, not a Redis problem. The packaged unit setsProtectHome,ReadOnlyPathsandPrivateTmp, and pointingdirorlogfileat a path outside what the unit permits fails before Redis runs at all. Either move the path back under/var/lib/redis, or add a drop-in granting access withReadWritePaths=. Inspect the effective unit withsystemctl cat redis-server.- The bind address does not exist on the host. Redis exits if it cannot bind every address listed. A
bindline copied from another machine naming an IP this host does not have fails immediately. The journal names the address. - A corrupt or unreadable dump.rdb or appendonly file. Redis refuses to start rather than serve partial data. The journal says so explicitly. Check ownership first, since this is usually a permissions problem rather than real corruption. Move the file aside only when you are willing to lose its contents.
- Port 6379 already bound. Usually a second Redis instance or a stale process:
sudo ss -tlnp | grep ':6379 '
What is not the cause
Two Redis log lines look alarming and are routinely blamed for startup failures they did not cause. The memory overcommit warning (Memory overcommit must be enabled) and the THP warning are both advisory. Redis logs them and keeps running. They are worth fixing for production stability, but if your service will not start, the cause is further down the log. Do not stop reading at the first scary line.
Likewise a WARNING: The TCP backlog setting of 511 cannot be enforced line is informational. Keep looking for an error that actually precedes the exit.
Reading the exit code
status=1/FAILURE means Redis started and rejected something, so read the journal. status=226/NAMESPACE means the unit’s sandboxing blocked a path, covered above. status=137 is SIGKILL, which for Redis is either the OOM killer or systemd timing out a Type=notify unit that never signalled readiness, which brings you back to the supervised setting at the top of this page. The full table is in the nginx version of this error.
How to stop it happening again
# prove the config parses before restarting anything sudo -u redis redis-server /etc/redis/redis.conf --test-memory 0 2>&1 | head -5
Redis has no dedicated configuration test, so the practical substitute is starting it as the redis user in the foreground and watching the first few lines. That catches permissions, bad bind addresses and unreadable data files in one go. If those lines look clean, stop it and start the service normally.
Related
- Job for nginx.service failed: the same systemd error, plus the full exit-code table.
- Job for postgresql.service failed: another data service where permissions on the data directory are the usual cause.
- systemd service unit generator: build a unit with the right Type and sandboxing rather than copying one and hoping.
Redis runs fine with redis-server but not with systemctl
That single symptom points almost exclusively at the supervised and daemonize mismatch at the top of this page. Running it by hand bypasses systemd entirely, so neither setting matters. Through systemd both must agree with the unit’s Type. Check both lines in the config and compare against systemctl show redis-server -p Type.
Is the service called redis or redis-server?
On Debian and Ubuntu the unit is redis-server.service, with redis.service as an alias, so both usually work. On RHEL family systems it is redis.service. If a command reports the unit was not found, list what actually exists with systemctl list-units 'redis*' --all before assuming it is uninstalled.
Leave a Reply