Hey, tryng to use redis-server with new ubuntu server 20.04, but i get always same error: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted

Any ideas ? Thnaks.

Comment From: itamarhaber

Hello @janarzz

This sounds like an installation glitch - how did you install Redis on the server?

Comment From: janarzz

sudo apt install redis-server

Comment From: rvlewerissa

Hi I received this problem too, any resolution?

Comment From: Barmunksu

i have the same error

Comment From: SkySlab

I had this problem running Ubuntu 20.04 headless server. The issue for me was a default setting in the configuration file (in Ubuntu 20.04, this was located at /etc/redis/redis.conf) for the port. It was set to port 0, I edited the config file and changed that to port 6379, also changed the maximum memory setting and bind settings (removing the ::1 from the end of 127.0.0.1.

Checking /var/log/redis/redis-server.log (using $ tail -40 /var/log/redis-server.log) the server started and was ready to accept connections.

Using $ redis-cli I was able to do a ping and it returned PONG.

Comment From: brendon

@janarzz, it's more like a warning from systemd as far as I can understand.

If you check /lib/systemd/system/redis-server.service you'll see the PID reference there. I suspect that Redis doesn't put the PID file there quickly enough for systemd and so it complains with the (yet?) part meaning that it might show up anyway.

Anyway, if you check that location, you'll see that the pid file does end up being there.

Not sure what can be done to prevent the message unfortunately.

Comment From: vidux

i'm having same issue.. is it a permission issue? Redis redis-server with ubuntu server 20.04

Comment From: OmgImAlexis

@vidux I found I was installing the wrong version. Make sure that's actually the latest and not something like v4.x.x.

Comment From: vidux

@vidux I found I was installing the wrong version. Make sure that's actually the latest and not something like v4.x.x.

the command i used to install sudo apt install redis-server I installed version is 5.0.7. (in a digital ocean droplet, Ubuntu 20.04). I also installed Redis my desktop which is running Ubuntu 20.04. it also redis_version:5.0.7. but Redis website showing Stable (6.2) 😕 .. both desktop and droplet showing that error log.. but both working. looks like no major issue.

Comment From: DrKimpatrick

Am having the same issue ```redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: activating (start) since Tue 2021-08-10 06:19:46 UTC; 15s ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 63170 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 2326) Memory: 300.0K CGroup: /system.slice/redis-server.service

Aug 10 06:19:46 ip-172-31-30-11 systemd[1]: Starting Advanced key-value store... Aug 10 06:19:46 ip-172-31-30-11 systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted


**Comment From: Sulshag**

nano /etc/systemd/system/redis.service

[Service] ExecStop=/bin/kill -s TERM $MAINPID ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"

sudo systemctl daemon-reload sudo systemctl enable redis-server sudo systemctl restart redis.service


**Comment From: brendon**

@Sulshag, thanks for the tip. You should edit your comment and use back-ticks around your code so that it gets formatted correctly :)

**Comment From: nightwalker89**

> nano /etc/systemd/system/redis.service
> 
> ExecStop=/bin/kill -s TERM $MAINPID
> Add a new lineExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid" in [Service]
> 
> sudo systemctl daemon-reload
> sudo systemctl enable redis-server
> sudo systemctl restart redis.service

Thank @Sulshag it works now on Ubuntu

**Comment From: brendon**

This could be worth raising with Ubuntu? https://packaging.ubuntu.com/html/fixing-a-bug.html

Looks like an onerous process though :(

**Comment From: hogivano**

> nano /etc/systemd/system/redis.service
> 
> ExecStop=/bin/kill -s TERM $MAINPID
> Add a new lineExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid" in [Service]
> 
> sudo systemctl daemon-reload
> sudo systemctl enable redis-server
> sudo systemctl restart redis.service

Thanks @Sulshag it's still worked

**Comment From: WuWhite**

nano /etc/systemd/system/redis.service

ExecStop=/bin/kill -s TERM $MAINPID
Add a new lineExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid" in [Service]

sudo systemctl daemon-reload
sudo systemctl enable redis-server
sudo systemctl restart redis.service

Thank @Sulshag it works now on Ubuntu

**Comment From: jabowery**

port 0 appears in unixsocket instances (ie: not using TCP).

Could that be left over from some prior configuration as the origin of what SkySlab experienced?  

**Comment From: momen84**

> ```
> nano /etc/systemd/system/redis.service
> 
> [Service]
> ExecStop=/bin/kill -s TERM $MAINPID
> ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"  
> 
> sudo systemctl daemon-reload
> sudo systemctl enable redis-server
> sudo systemctl restart redis.service
> ```

Thanks @Sulshag  ..... it worked for me

**Comment From: andrewborell**

why not just edit _/etc/redis/redis.conf_ and configure ` unixsocketperm 770 ` instead of the default config of  `unixsocketperm 700 ` ?


**Comment From: intelliant01**

I suggest to check for the real reason in `/var/log/redis/redis-server.log`. 
For example, I was getting the same error as reported above but the real reason was that I had disabled IPv6 and hence had to remove `::1` from `bind 127.0.0.1 ::1` in `/etc/redis/redis.conf`. Simply removing this, fixed it all.

**Comment From: madolson**

Everyone is more than welcome to keep responding, but closing this since this doesn't look like a redis issue.

**Comment From: intelliant01**

@madolson why isn't this a redis issue? If IPv6 is disabled on a system then redis should not attempt to bind to `::1` which is the default configuration that is breaking redis. Should the startup routine not check the system setting and gracefully skip trying to bind to `::1`? 
Even the systemctl status messages are misleading and the root cause unknown unless one checks the logs.

**Comment From: Ziggizag**

So,

For me the only working solution was commenting out this line of the `/etc/systemd/system/redis.service` file:

`PIDFile=/run/redis/redis-server.pid`

So now it goes:

[Service] Type=forking ExecStart=/usr/bin/redis-server /etc/redis/redis.conf

PIDFile=/run/redis/redis-server.pid

TimeoutStopSec=0 Restart=always User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=2755


Since then the issue is gone for good.
Ubuntu 20.04 LTS on WSL2.



**Comment From: duynv1609**

> ```
> nano /etc/systemd/system/redis.service
> 
> [Service]
> ExecStop=/bin/kill -s TERM $MAINPID
> ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"  
> 
> sudo systemctl daemon-reload
> sudo systemctl enable redis-server
> sudo systemctl restart redis.service
> ```

Thank you for your tip, it worked for me

**Comment From: ngtuan96lc**

>  

Thanks @Sulshag 
It worked for me!

**Comment From: igorlcs**

> 
Thanks @Sulshag, it worked in Linux Mint 20.3 Cinnamon.

**Comment From: electrocoder**

Thanks @Sulshag 

**Comment From: wmullaney**

This is still an issue. Fresh Ubuntu 20.04 install. Followed the documentation to the letter and still received this error. The suggestions here did not help so I am deleting the instance and doing everything all over again. I would almost rather drink mercury than f@#$ with this redis half ass documentation. 

**Comment From: itamarhaber**

To be crystal clear - the default redis packages that come from distributions (such as Ubuntu) are not maintained by the Redis project, half-assed or not, hence this issue is treated as closed and irrelevant.

You can follow the instructions on [this page](https://redis.io/docs/getting-started/installation/install-redis-on-linux/#install-on-ubuntudebian) to get the project's official .debs. AFAIK, WSL is a problem due to its lack of/problematic support for systemd.

**Comment From: alexandru-eftimie**

One other option is to configure redis to play well with systemd.

/etc/redis/redis.conf:
```conf
daemonize yes
supervised systemd
pidfile /var/run/redis/redis-server.pid

/etc/systemd/system/redis.service:

[Service]
...
Type=notify
PIDFile=/run/redis/redis-server.pid
...

And completely skip ExecStop and ExecStartPost. On a ubuntu 20.04, this was the only way it actually worked as $MAINPID was always empty.

Comment From: zachGl

I was getting the same error but the solution was completely different.

The port 6379 was used by a previous version of redis-server which was still running. I found the error in /var/log/redis/redis-server.log Everything worked fine after I stopped the previous redis-server

Comment From: LuisFerchx

Oye, trato de usar redis-server con el nuevo servidor ubuntu 20.04, pero siempre recibo el mismo error: redis-server.service: Can't open PID file /run/redis/redis-server.pid (todavía?) después del inicio: operación no permitida

Algunas ideas ? Gracias.

Hey, tryng to use redis-server with new ubuntu server 20.04, but i get always same error: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted

Any ideas ? Thnaks.

I just restart my Ubuntu machine and Redis run xD

Comment From: danielemuze

In my case, I used this in my service file and it solved the issue:

[Unit] Description=Redis After=network.target

[Service] Type=forking PIDFile=/run/redis/redis_6379.pid ExecStart=redis-server /opt/redis-stable/redis.conf ExecStop=redis-cli shutdown User=root Group=root Restart=always RestartSec=5s ExecStartPost=sh -c "if [ ! -d '/var/run/redis' ]; then mkdir /var/run/redis; fi && touch /var/run/redis/redis_6379.pid && echo > $(netstat -ntlp | grep ':6379' | awk '{print $7}' | cut -d'/' -f1)"

[Install] WantedBy=multi-user.target

Comment From: SalamandraDevs

Hey, tryng to use redis-server with new ubuntu server 20.04, but i get always same error: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted

Any ideas ? Thnaks.

Look at this post. https://stackoverflow.com/questions/25515166/redis-daemon-not-creating-a-pid-file

Comment From: powelino

``` nano /etc/systemd/system/redis.service

[Service] ExecStop=/bin/kill -s TERM $MAINPID ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"

sudo systemctl daemon-reload sudo systemctl enable redis-server sudo systemctl restart redis.service ```

Thank you for your tip, it worked for me

Hi, I I am having the same issue. Now I pasted this command in SSH. What else do I have to do. Hit enter? I have too many options. Please see the screenshot: https://prnt.sc/PplWAZuUw6Ak