GrepBoard/Manuals
605 manuals ·

Fix systemd status=200/CHDIR (WorkingDirectory failed)

·Tested on Ubuntu 24.04 (Docker) · chdir reproduction · systemd 255 source and official docs · 2026-10·Test scope ↓·6 steps

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.

text
code=exited, status=200/CHDIRChanging to the requested working directory failed: No such file or directory

200/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.

console
# 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:

console
# env -C /srv/app/current true
output
env: cannot change directory to '/srv/app/current': No such file or directory
console
# setpriv --reuid=nobody --regid=nogroup --clear-groups env -C /srv/app/private true
output
env: cannot change directory to '/srv/app/private': Permission denied
Final wordsReproduced caseNext
No such file or directoryThe path does not exist, or a symlink points at a deleted target (current -> releases/v1)[3]
Permission deniedThe 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.

console
# namei -l /srv/app/current
output
f: /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 directory

Here 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.

console
# namei -l /srv/app/private
output
f: /srv/app/privatedrwxr-xr-x root root /drwxr-xr-x root root srvdrwxr-xr-x root root appdrwx------ root root private

Every 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.

console
# getent passwd nobody
output
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin

If 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.

/etc/systemd/system/myapp.service.d/override.conf
[Service]WorkingDirectory=-/srv/app/current

The 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.

#systemd#200-chdir#workingdirectory#service