Here's my situation whenever I reboot:

$ systemctl --failed
nginx.service loaded failed failed A high performance web server and a reverse proxy server
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2014/01/18 05:44:47 [emerg] 254#0: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
$ cd /run
$ ls -al | grep nginx
$ sudo systemctl start nginx
$ ls -al | grep nginx
-rw-r--r--  1 root     root        4 Jan 18 06:27 nginx.pid

I don't understand how nginx.pid could have incorrect permissions before it's even created, or what one would do to resolve that.

I'm using Arch and I've seen similar issues relating to chroot-jail, but I did not install nginx in a chroot.

  • I would suggest that you ensure that there doesn't already exist a pid file with wrong owner or permission. I had a similar issue where I was running uwsgi in a python virtual env and pid file was not accessible because there was already a pid file existing with wrong permissions which someone had created earlier.
    – APZ
    Jan 18, 2014 at 19:43
  • Thanks for taking a look. That was my first thought as well, which is why I cd'd to /run and greped for the file. As you can see above, the pid file isn't created until I manually start nginx. I tried changing the permissions, but they're reset after each reboot. Jan 18, 2014 at 19:58
  • 1
    I am a Ubuntu user mainly and whenever I have start nginx or any service I use sudo . I see you doing nginx -t (not sure of the whole systemctl functioning) but it might be worth check as what user is nginx trying to start because pid is owned by root.
    – APZ
    Jan 18, 2014 at 20:28

2 Answers 2


The issue seems to be you are using an unprivileged user to test the Nginx configuration. When the test occurs, it attempts to create /run/nginx.pid, but fails and this causes the configuration test to fail. Try running nginx as root.

$ sudo nginx -t


$ su - -c "nginx -t"

This way, the Nginx parent process will have the same permission it would when run by systemctl.

If this resolves the error at testing, but not when run from systemctl, you may want to check this page on investigating systemd errors.


For me, I just changed the selinux from enforcing to permissive and then I was able to start nginx without any error.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .