nginx 1.31.8 working_directory now relative to prefix: check it
nginx 1.31.8 resolves a relative working_directory against the prefix. A missing path leaves 1.31.7 running with no workers; 1.31.8 refuses to start.
nginx: [emerg] stat() "/etc/nginx/cores" failed (2: No such file or directory)If nginx stops starting with this error after an upgrade to 1.31.8, your working_directory uses a relative path that is now looked up under the nginx prefix. Switch to an absolute path or create the directory under the prefix. The two entries from the 1.31.8 changelog (2026-10-21):
*) Change: now the path specified in the "working_directory" directive is relative to nginx prefix directory, but not to the current directory. *) Bugfix: worker processes exited on start or during reconfiguration if an invalid directory was specified in the "working_directory" directive.working_directory sets the current directory of worker processes and is mostly used to choose where core files go. If your configuration has no such line, nothing here applies.
[1] Find relative paths in the configuration. Any value that does not start with / is affected.
$ sudo nginx -T 2>/dev/null | grep -n 'working_directory'[2] Check the prefix. From 1.31.8 relative paths resolve under it. Starting nginx with -p overrides it.
$ nginx -V 2>&1 | tr ' ' '\n' | grep -- '--prefix'--prefix=/etc/nginxThat is the value in the official Docker image. Distribution packages may differ, so check on your own server.
[3] See how each version reads the same setting. With working_directory cores;, the cores directory was created only under the start directory / (case A) or only under the prefix /etc/nginx (case B). The worker's real directory was read from /proc/<pid>/cwd.
| Case | 1.31.7 | 1.31.8 |
|---|---|---|
A: only /cores exists | Runs, worker cwd /cores | Fails to start, stat() "/etc/nginx/cores" failed |
B: only /etc/nginx/cores exists | Master only; worker exits and is not respawned | Runs, worker cwd /etc/nginx/cores |
The log for 1.31.7, case B. The master stays up, so a process monitor sees nothing wrong, but there is no worker to serve requests.
2026/10/27 03:45:51 [alert] 8#8: chdir("cores") failed (2: No such file or directory)2026/10/27 03:45:51 [notice] 1#1: signal 17 (SIGCHLD) received from 82026/10/27 03:45:51 [notice] 1#1: worker process 8 exited with code 22026/10/27 03:45:51 [alert] 1#1: worker process 8 exited with fatal code 2 and cannot be respawnedThe container stayed running in this state. If you use working_directory on 1.31.7 or older, search the error log for cannot be respawned once.
[4] Catch it with nginx -t before upgrading. The same configuration file with a missing relative path (working_directory missing;) was tested on both versions. 1.31.7 accepted it:
$ nginx -t -c /srv/test/nginx.confnginx: the configuration file /srv/test/nginx.conf syntax is oknginx: configuration file /srv/test/nginx.conf test is successful1.31.8 rejects the same file. The error is printed twice, once by the error log on stderr and once on the console:
$ nginx -t -c /srv/test/nginx.confnginx: the configuration file /srv/test/nginx.conf syntax is ok2026/10/27 03:46:12 [emerg] 1#1: stat() "/etc/nginx/missing" failed (2: No such file or directory)nginx: [emerg] stat() "/etc/nginx/missing" failed (2: No such file or directory)nginx: configuration file /srv/test/nginx.conf test failedRunning nginx -t with the new binary tells you about the start failure before you switch. The path in the error is where 1.31.8 actually looks.
[5] Fix the path. An absolute path points to the same place on every version.
working_directory /var/tmp/nginx-cores;The worker user (the account in the user directive) must be able to write there for core files to appear; the documentation says the same.
$ sudo mkdir -p /var/tmp/nginx-cores$ sudo chown www-data /var/tmp/nginx-cores$ sudo nginx -t && sudo systemctl reload nginxReplace www-data with the account from the user directive in nginx -T. To undo, restore the - line and reload. Keep in mind that on 1.31.8 cores now means <prefix>/cores; to keep the old location, write it as an absolute path.
Analyze your Nginx log in the browser ↗ — nothing is uploaded.