Bobcares

Failed to parse pid from file /run/nginx.pid invalid argument

by | Aug 18, 2022

Let us take a  closer look into the failed to parse PID from file /run/nginx.pid invalid argument error and how to manage and eradicate it. We at Bobacres can give you a complete guide on how to tackle the Failed to parse PID from file error with our Server management support services.

Failed to parse PID error

 

failed to parse pid from file /run/nginx.pid invalid argument

The Nginx service is operational, however, an error message appears as shown below:

nginx systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument

The error appears with the ‘failed to parse pid from file /run/nginx.pid invalid argument’ statement. This is an example of Nginx and systemd fighting over resources. This warning is unimportant since systemd only uses the PIDFile option to remove PIDFile after the Nginx service has terminated. There are two ways to prevent or clear the failed to parse PID, invalid argument error, which is below:

Option 1: Create the PID file for failed to parse pid from file /run/nginx.pid invalid argument

In the first option, the initial step to fix the error is to manually create the PID file. Follow the steps listed down below to test out the first option.

Step 1. Create the directory /etc/systemd/system/nginx.service.d

Create a directory with the name nginx.service.d in /etc/systemd/system/:

mkdir /etc/systemd/system/nginx.service.d

If the system complains that it already exists, disregard it and proceed to Step 2. This is the first step in eliminating the failed to parse PID from file invalid argument error.

Step 2. Print data to file

The next step is to print data to file then Execute:

printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" /etc/systemd/system/nginx.service.d/override.conf

This is a one-sentence sentence. The output of printf will be sent to the configuration file /etc/systemd/system/nginx.service.d/override.conf.

Step 3. Reload the Daemon

The next step is to, Reload systemd manager configuration for tackling the failed to parse :

systemctl daemon-reload

All generators will be running, all unit files will be reloaded, and the whole systemd dependency tree will be recreated. This will automatically reset and eliminate the failed to parse PID from file invalid argument error.

Step 4. Restart NGINX

The next step is to reboot the NGINX, the line given below will reboot the NGINX:

systemctl restart nginx

The failed to parse PID error invalid argument error; should now be corrected post the NGINX restart.

Option 2: An alternative workaround for failed to parse PID from file /run/nginx.pid invalid argument error

Another approach is to remove the pidfile option and replace it with the line:

ExecStopPost=/bin/rm -f /run/nginx.pid

or

ExecStartPost=/bin/sleep 1

to /usr/lib/systemd/system/nginx.service.

Finally, check to see if there is an nginx.pid error and if Nginx is operating and is possible to connect to port 80 on the server. If the problem persists, it is possible that SELinux is prohibiting php-fpm from accessing a port. Try typing in the following:

journalctl -xe

[Need assistance with similar queries? We are here to help]

Conclusion

To conclude, failed to parse PID from file /run/nginx.pid invalid argument error is an easy fix. And, there are two major options to deal with it.  A user can choose from the methods to eradicate the error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

1 Comment

  1. Dmitry

    Nice! Good solution (Option 1)! ?
    And we can also add line “ExecStartPost=/bin/sleep 0.1” to [Service] of nginx.service file…

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.