Fix systemd status=200/CHDIR (WorkingDirectory failed)
systemd status=200/CHDIR: the service could not enter WorkingDirectory=. The journal's last words separate a missing path, User= permissions or a missing home.
code=exited, status=200/CHDIRChanging to the requested working directory failed: No such file or directory200/CHDIR does not mean the program ran and crashed. Right before starting it, systemd **could not change into WorkingDirectory=**. The systemd manual (systemd.exec, Process Exit Codes) describes 200 as "Changing to the requested working directory failed." The words after Changing to the requested working directory failed: in the journal tell you why. The second line of the first block is the wording from the systemd 255 source; the final words are the error returned by chdir(2).
[1] Find that line's ending in the journal.
# journalctl -u myapp -b --no-pager -n 20# systemctl cat myapp | grep -E 'WorkingDirectory|User|RootDirectory'[2] Narrow it down by those final words. These are the errors from the same chdir(2) call systemd makes, invoked with env -C (coreutils) in an Ubuntu 24.04 container:
# env -C /srv/app/current trueenv: cannot change directory to '/srv/app/current': No such file or directory# setpriv --reuid=nobody --regid=nogroup --clear-groups env -C /srv/app/private trueenv: cannot change directory to '/srv/app/private': Permission denied| Final words | Reproduced case | Next |
|---|---|---|
No such file or directory | The path does not exist, or a symlink points at a deleted target (current -> releases/v1) | [3] |
Permission denied | The path exists but the User= account cannot enter it | [4] |
[3] For No such file or directory, follow the path step by step. namei shows where a symlink breaks.
# namei -l /srv/app/currentf: /srv/app/currentdrwxr-xr-x root root /drwxr-xr-x root root srvdrwxr-xr-x root root applrwxrwxrwx root root current -> /srv/app/releases/v1… v1 - No such file or directoryHere a deploy tool left the current link pointing at an old release and then deleted that folder. Point the link at the new release or create the directory. If the service uses RootDirectory=, the manual says WorkingDirectory= is relative to that root, so the folder must exist inside it.
[4] For Permission denied, check the path as the service user. The systemd source switches to User= before entering the working directory (a comment explains this is for cases such as NFS where only that user has access). So a cd as root looks fine; in the reproduction root could enter the same folder.
# namei -l /srv/app/privatef: /srv/app/privatedrwxr-xr-x root root /drwxr-xr-x root root srvdrwxr-xr-x root root appdrwx------ root root privateEvery step of the path needs execute (x) permission for that user. Here private is mode 700 owned by root. Give the folder to the service user (chown myapp: /srv/app/private) or grant the group x. Widening parent folders opens them to other accounts too, so change only the step that blocks.
[5] WorkingDirectory=~ means the home directory of User=. If that account's home does not actually exist, you get the same 200. In the reproduction container, nobody had /nonexistent as its home.
# getent passwd nobodynobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologinIf the service account was created with useradd --system and no home, write the real path instead of ~. Per the source, failing to determine the home directory at all also yields 200, and the journal then says Failed to determine $HOME for user:.
[6] If the service can live without the folder, prefix the path with -. The manual says that with - "a missing working directory is not considered fatal", and the source ignores the chdir failure in that case.
[Service]WorkingDirectory=-/srv/app/currentThe program then starts somewhere other than the intended folder, so a program that opens files by relative path will just fail with a different error. After the change, run systemctl daemon-reload and restart.
If the executable itself could not be opened, see status=203/EXEC. For the general checklist, see finding why a service failed.
Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.