Describe the bug
On Ubuntu Server 20.04, Redis (5.0.7) doesn't start after setting supervised systemd on /etc/redis/redis.conf, but no error is printed when running it manually with /usr/bin/redis-server /etc/redis/redis.conf.
Also, when running manually, its possible to find it listening on port 6379 with netstat -tulpn.
To reproduce
As root:
- Update packages and install Redis with apt update && apt install redis-server
- On /etc/redis/redis.conf, change the line with supervised no to supervised systemd
- Try to restart Redis with service redis-server restart or systemctl restart redis
The output of the above command is:
Job for redis-server.service failed because the control process exited with error code.
See "systemctl status redis-server.service" and "journalctl -xe" for details.
And the output of systemctl status redis-server.service is:
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-02-03 12:15:56 -03; 28s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 3851 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
Feb 03 12:15:56 mywebsite.com systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 5.
Feb 03 12:15:56 mywebsite.com systemd[1]: Stopped Advanced key-value store.
Feb 03 12:15:56 mywebsite.com systemd[1]: redis-server.service: Start request repeated too quickly.
Feb 03 12:15:56 mywebsite.com systemd[1]: redis-server.service: Failed with result 'exit-code'.
Feb 03 12:15:56 mywebsite.com systemd[1]: Failed to start Advanced key-value store.
Expected behavior
To be able to restart and use Redis normally, without errors.
Additional information
No log is printed on /var/log/redis/redis-server.log when trying to restart Redis service, but the text below is printed when running it manually:
4231:C 03 Feb 2021 12:27:52.053 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4231:C 03 Feb 2021 12:27:52.053 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=4231, just started
4231:C 03 Feb 2021 12:27:52.053 # Configuration loaded
4232:M 03 Feb 2021 12:27:52.063 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 4232
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
4232:M 03 Feb 2021 12:27:52.065 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4232:M 03 Feb 2021 12:27:52.065 # Server initialized
4232:M 03 Feb 2021 12:27:52.066 * Ready to accept connections
Software versions: Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923 Ubuntu 20.04.2 LTS - 64 bit systemd 245 (245.4-4ubuntu3.4)
Comment From: paulocoghi
Closing. For an unknown reason, the owner or permissions on /var/lib/redis and/or /var/log/redis and/or /var/run/redis were not ok. I changed to redis:redis and now, everything is fine.
Comment From: anushkrishnav
Hey @paulocoghi how did you fix this issue I am facing exactly the same problem
Comment From: paulocoghi
@anushkrishnav, it's better to not change the supervised setting on /etc/redis/redis.conf, as I said initially on this issue.
If Redis doesn't work with the original supervised setting, the solution is to completely remove Redis, update your repositories and install it again, with:
sudo apt purge redis-server
sudo rm -rf /etc/redis
sudo apt update
sudo apt install redis-server
Comment From: yngfoxx
Just want to add this in-case it helps someone
in my situation, there was another process using the same port number as the redis-server.
use this lsof -i -P -n | grep LISTEN to view services actively listening so you can solve your new problem 😉