GrepBoard/Manuals
605 manuals ·

Fix systemd status=226/NAMESPACE (Failed at step NAMESPACE)

·Tested on systemd official docs (latest) and v255 source · 2026-10·Test scope ↓·5 steps

systemd 226/NAMESPACE means the service mount, UTS or IPC namespace failed. Find the missing ReadWritePaths or BindPaths path in the journal and fix it.

text
code=exited, status=226/NAMESPACEFailed to set up mount namespacing: /var/lib/myapp: No such file or directoryFailed at step NAMESPACE spawning /usr/bin/myapp: No such file or directory

226/NAMESPACE is the exit code systemd uses when it fails to build the service's private mount, UTS or IPC namespace just before starting the process, and the path after Failed to set up mount namespacing: in the journal tells you where it stopped. If that path is a directory that does not exist, create it or take it out of the unit. The block above is the shape of the message from the systemd 255 source, not captured output; the path and the final error differ from case to case.

The manual (systemd.exec, Process Exit Codes) describes 226 as "Failed to set up mount, UTS, or IPC namespacing. See ReadOnlyPaths=, ProtectHostname=, PrivateIPC=, and related settings." This page covers the mount side, the one you usually meet first (the options that take paths). No real service was started; the behavior below follows the manual and the systemd 255 source.

[1] Read the journal line just before Failed at step NAMESPACE.

console
# journalctl -u myapp -b --no-pager -n 20

In the source, when the mount namespace step fails, systemd prints Failed to set up mount namespacing followed by the path of the mount that failed. A comment in namespace.c gives the example: with a BindPaths=/var/bar that does not exist on the host, the message is Failed to set up mount namespacing: /var/bar: No such file or directory. If you only get an error with no path, the path cannot narrow it down; go to [4].

[2] Check whether that path exists and which option uses it.

console
# ls -ld /var/lib/myapp# systemctl cat myapp# systemctl show -p ReadWritePaths -p ReadOnlyPaths -p InaccessiblePaths -p BindPaths -p BindReadOnlyPaths -p ProtectSystem -p ProtectHome myapp

systemctl cat prints the unit file and every drop-in, so you can tell whether the offending line is in the main file or in a drop-in.

Per the manual, entries in ReadWritePaths=, ReadOnlyPaths=, InaccessiblePaths=, ExecPaths= and NoExecPaths= are ignored when missing only if prefixed with -. A BindPaths= or BindReadOnlyPaths= definition prefixed with - is ignored when its source does not exist or is not accessible. Without the -, a missing path produces the error above. The systemd 255 source agrees: the remount step passes over ENOENT only when the entry carries that "ignore" flag.

[3] If the path is missing, create the directory first. It leaves the unit untouched, so it is the safest fix.

console
# mkdir -p /var/lib/myapp# chown myapp:myapp /var/lib/myapp# systemctl restart myapp

Use the account from the unit's User= for chown. If the directory is just the service's own data, StateDirectory=myapp (which maps to /var/lib/myapp) lets systemd create it; the manual says StateDirectory= and its siblings are also excluded from the read-only effect of ProtectSystem=.

For a path that should not be created (a mount point that exists only sometimes), put - in front of it. If you would rather not edit the main file, add a new drop-in with a different file name, clear the list, and write it again. The manual says assigning an empty value resets everything assigned before, so list every path you want to keep.

Per systemd.unit, drop-ins with different names are applied in lexicographic order, so the new file must sort after every file that assigns the path you are replacing. Run systemctl cat myapp to see the existing drop-ins (override.conf, 50-*.conf and so on) and pick a later-sorting name (zz- below). A name that sorts earlier gets the later file's paths appended again after the reset, and the 226 stays.

/etc/systemd/system/myapp.service.d/zz-paths.conf
[Service]ReadWritePaths=ReadWritePaths=-/var/lib/myapp /var/log/myapp
console
# systemctl daemon-reload# systemctl show -p ReadWritePaths myapp# systemctl restart myapp

Read the show output before restarting: the missing path must be gone, or carry the - prefix.

[4] If the path is not the problem, look at the environment. The manual says /run/ has to be writable for the mount namespace and propagation setup, and that a BindPaths= destination cannot sit under InaccessiblePaths= or under /home/ when ProtectHome=yes is set (the destination must exist or be creatable by systemd). The manual's advice for that case is TemporaryFileSystem= with :ro, or ProtectHome=tmpfs.

For a systemctl --user service, these options work only in a user instance where PrivateUsers= is implicitly enabled, and the manual says that requires unprivileged user namespaces to be allowed in the kernel through kernel.unprivileged_userns_clone. If your distribution or container blocks it, a user service that uses sandbox options may fail to start. The exact log text in that case was not confirmed.

[5] When 226 comes from the UTS or IPC side (ProtectHostname=, PrivateIPC=), the journal says Failed to set up UTS namespacing or Failed to set up IPC namespacing. In the 255 source, failing to create a UTS namespace is not treated as an error when the kernel lacks support or privileges are missing (ERRNO_IS_NOT_SUPPORTED, ERRNO_IS_PRIVILEGE); only other errors end in 226. PrivateIPC=yes with EPERM just logs an "ignoring" warning. The exception is IPCNamespacePath= set on a kernel without IPC namespace support: the source ends that in 226 and the journal reads IPCNamespacePath= is not supported, refusing. Any other 226 from UTS or IPC is some error other than missing privileges or support, and the error text at the end of that journal line is what to search for.

Other exit codes: 200/CHDIR, 203/EXEC and 217/USER. For the general order of checks see when a service is failed.

Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.

#systemd#226-namespace#readwritepaths#bindpaths#protectsystem