nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nginx (Debian) |
Fix Released
|
Unknown
|
|||
nginx (Ubuntu) |
Fix Released
|
Low
|
Thomas Ward | ||
Xenial |
Won't Fix
|
Low
|
Unassigned | ||
Bionic |
Won't Fix
|
Low
|
Unassigned | ||
Cosmic |
Won't Fix
|
Low
|
Unassigned | ||
Disco |
Won't Fix
|
Low
|
Unassigned | ||
Eoan |
Fix Released
|
Low
|
Thomas Ward |
Bug Description
[Description]
Nginx logs an error when started on a machine with a single CPU:
systemctl start nginx
systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/
Active: active (running) since Sat 2016-05-14 19:35:03 UTC; 2s ago
Process: 1303 ExecStop=
Process: 1307 ExecStart=
Process: 1306 ExecStartPre=
Main PID: 1308 (nginx)
Tasks: 5 (limit: 512)
Memory: 3.1M
CPU: 81ms
CGroup: /system.
├─1308 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
├─1309 nginx: worker process
├─1310 nginx: worker process
├─1311 nginx: worker process
└─1312 nginx: worker process
May 14 19:35:03 ngx systemd[1]: Starting A high performance web server and a reverse proxy server...
May 14 19:35:03 ngx systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
May 14 19:35:03 ngx systemd[1]: Started A high performance web server and a reverse proxy server.
Bumping the number of CPU available makes the error disappear. This is reproducible on VMs and containers.
Lastly, the PID file is properly created and matches the PID of the master process.
[Workaround]
sudo mkdir /etc/systemd/
printf "[Service]
sudo tee /etc/systemd/
sudo systemctl daemon-reload
sudo systemctl restart nginx
[Additional information]
# lsb_release -rd
Description: Ubuntu 16.04 LTS
Release: 16.04
# apt-cache policy nginx-core
nginx-core:
Installed: 1.10.0-
Candidate: 1.10.0-
Version table:
*** 1.10.0-
500 http://
100 /var/lib/
1.
500 http://
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: nginx-core 1.10.0-
ProcVersionSign
Uname: Linux 4.4.0-22-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
Date: Sat May 14 19:35:21 2016
ProcEnviron:
TERM=xterm
PATH=(custom, no user)
SourcePackage: nginx
UpgradeStatus: No upgrade log present (probably fresh install)
Changed in nginx (Debian): | |
importance: | Undecided → Unknown |
status: | New → Unknown |
Changed in nginx (Debian): | |
status: | Unknown → New |
description: | updated |
description: | updated |
Changed in nginx (Ubuntu Disco): | |
status: | New → Confirmed |
Changed in nginx (Ubuntu Cosmic): | |
status: | New → Confirmed |
Changed in nginx (Ubuntu Bionic): | |
status: | New → Confirmed |
Changed in nginx (Ubuntu Xenial): | |
status: | New → Confirmed |
Changed in nginx (Ubuntu Disco): | |
importance: | Undecided → Low |
Changed in nginx (Ubuntu Cosmic): | |
importance: | Undecided → Low |
Changed in nginx (Ubuntu Bionic): | |
importance: | Undecided → Low |
Changed in nginx (Ubuntu Xenial): | |
importance: | Undecided → Low |
Changed in nginx (Ubuntu Eoan): | |
status: | Confirmed → Fix Committed |
Changed in nginx (Ubuntu Disco): | |
status: | Confirmed → Won't Fix |
Changed in nginx (Ubuntu Xenial): | |
status: | Confirmed → Won't Fix |
tags: | added: packaging |
Changed in nginx (Debian): | |
status: | New → Fix Released |
tags: | added: server-triage-discuss |
It seems to be a race between systemd and nginx. As if systemd was expecting the PID file to be populated before nginx had the time to create it.
Workaround:
printf "[Service] \nExecStartPost =/bin/sleep 0.1\n" > /etc/systemd/ system/ nginx.service. d/override. conf
systemctl daemon-reload