Unable to start nginx - failed to read pid from file /run/nginx.pid

November 7, 2014 15.5k views


I just created a brand new fedora box.

I then install nginx by running yum install nginx.

I tried to start nginx with the following commands:

$ systemctl enable nginx
$ systemctl restart nginx

However, I got the following error

Failed to read PID from file /run/nginx.pid: Invalid argument

And nginx is not running properly (going to the public IP address of the box does not return anything.

Does anyone know what I did wrong?

2 Answers

That pid error is often simply caused by restarting Nginx when it isn't started in the first place. Though the init script should be smart enough to fall back from restart to start. So I don't think that's the real problem here. Check to see that Nginx is running and the port that it is listening on by running: netstat -plunt | grep nginx

On Fedora 20, firewalld is running by default. Have you opened port 80?

If the netstat output shows that it is running, then the firewall is most likely your problem. To open the port, run:

firewall-cmd --permanent --zone=public --add-service=http
systemctl restart firewalld.service
  • hi,just like you say,I try:netstat -plunt | grep nginx
    print like that:
    tcp 0 0* LISTEN 2370/nginx: master

    tcp 0 0* LISTEN 2370/nginx: master

    tcp6 0 0 :::80 :::* LISTEN 2370/nginx: master

    tcp6 0 0 :::443 :::* LISTEN 2370/nginx: master

    [root@iZ943xbvop0Z ssl]# firewall-cmd --permanent --zone=public --add-service=http
    FirewallD is not running

    [root@iZ943xbvop0Z ssl]# systemctl restart firewalld.service
    Failed to issue method call: Unit firewalld.service is masked.

    how to solve the problem?

I'm curious, did you resolve this issue?

Have another answer? Share your knowledge.