42

I Installed Redis Server on ubuntu 16.04. but when I try to start the redis service using

$ sudo systemctl start redis

I receive message:

Failed to start redis.service: Unit redis-server.service is masked.

I don't have any idea about this error.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Raza Rafaideen
  • 2,119
  • 1
  • 19
  • 30

5 Answers5

68

I found the solution. I think it will help for others | systemctl unmask servicename

$ sudo systemctl unmask  redis-server.service
Raza Rafaideen
  • 2,119
  • 1
  • 19
  • 30
  • 15
    On Ubuntu 20, turned out I needed to call `sudo systemctl restart redis-server` instead of `sudo systemctl restart redis`, doh! – Xunnamius May 04 '21 at 06:15
19

if redis.service file is missed in directory path /etc/systemd/system/redis.service so we have to create file into this directory using command like:

sudo nano /etc/systemd/system/redis.service and write following things

[Unit]
Description=Redis In-Memory Data Store 
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

Here

  • Unit is description and defining the network behavior,
  • Service is to specify the service's behavior and
  • Install define the systemd target that the service should attach to if enabled.

Then create redis user group and directories using

sudo adduser --system --group --no-create-home redis
  1. sudo mkdir /var/lib/redis (Create directory)
  2. sudo chown redis:redis /var/lib/redis (Change owner permission)
  3. sudo chmod 770 /var/lib/redis

run the service sudo systemctl start redis It will be work fine and check the status using

sudo systemctl status redis
  • I started redis-server with `redis-server /path/to/redis.conf` now, how can I check the status of my redis-server?? @aniruddh – AATHITH RAJENDRAN May 25 '19 at 05:29
  • `sudo systemctl status redis` returns `Active: active (exited)`, why is not in RUNNING mode @aniruddh – AATHITH RAJENDRAN May 25 '19 at 08:30
  • In my case i had to first remove the already existing redis user with command `sudo userdel -r redis` – Ahtisham Jun 18 '21 at 08:51
  • 1
    This answer is missing a lot of important information if you want to install it on a centos server. I found a better explanation here: https://www.linuxcloudvps.com/blog/how-to-set-up-redis-on-centos-7/ – sz tech Aug 11 '21 at 11:47
6

For Ubuntu users run

sudo systemctl restart redis-server
logi-kal
  • 7,107
  • 6
  • 31
  • 43
user21051879
  • 61
  • 1
  • 1
1

1.sudo systemctl unmask redis-server.service

if redis.service file is missed in directory path

/etc/systemd/system/redis.service ,so we have to create file into this directory using command like:

sudo nano /etc/systemd/system/redis.service and write following things

[Unit]
Description=Redis In-Memory Data Store 
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

Then create redis user group and directories using

sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis (Create directory)
sudo chown redis:redis /var/lib/redis (Change owner permission)
sudo chmod 770 /var/lib/redis

run the service sudo systemctl start redis It will be work fine and check the status using

sudo systemctl status redis
Rajnish kumar
  • 186
  • 1
  • 14
ashique
  • 935
  • 2
  • 8
  • 26
-1

you must run code

sudo systemctl daemon-reload
Tinywan
  • 31
  • 3