Fix systemd status=217/USER (User= account not found)
systemd status=217/USER means the User= account was not found or could not be switched to. Tell a missing account, DynamicUser= or PrivateUsers= apart.
code=exited, status=217/USERFailed to determine user credentials: No such processFailed at step USER spawning /usr/bin/myapp: No such process217/USER means that just before starting the program, systemd **could not find the User= account or could not switch to it**. If the journal line before it is Failed to determine user credentials, the account is missing from the user database and creating it fixes the service; other messages split as in the table below. The manual (systemd.exec, Process Exit Codes) describes 217 as "Failed to determine or change user credentials, or to set up user namespacing. See User=/PrivateUsers= above." The block above is not captured output but the message text from the systemd 255 source; No such process is the ESRCH the source returns for a missing account.
[1] Read the line just before Failed at step USER in the journal.
# journalctl -u myapp -b --no-pager -n 20# systemctl show -p User -p DynamicUser -p PrivateUsers myapp| Preceding line (systemd 255 source text) | Cause | Go to |
|---|---|---|
Failed to determine user credentials: No such process | The User= name or UID is not in the user database | [2] |
Failed to update dynamic user credentials: User or group with specified name already exists. | DynamicUser=yes, but only a static group of that name exists | [3] |
Failed to set up user namespacing: … | The user namespace for PrivateUsers= could not be created | [4] |
Failed to change UID to …: … | The account was found, but setresuid() was refused | [5] |
[2] Check that the account exists with getent or id. systemd also looks it up through NSS (getpwnam()), so the answer matches. In an Ubuntu 24.04 container, getent passwd myapp for a missing account prints nothing and exits with status 2.
# id myappid: 'myapp': no such userA numeric User=4242 is no workaround. The source looks numeric UIDs up with getpwuid() as well and fails with the same No such process when the UID is not in the database.
Without DynamicUser=, the manual says the user "must have been created statically in the user database no later than the moment the service is started, for example using the sysusers.d(5) facility". Add one file and preview it with --dry-run:
u myapp - "myapp service" /var/lib/myapp# systemd-sysusers --dry-run /etc/sysusers.d/myapp.confCreating group 'myapp' with GID 996.Creating user 'myapp' (myapp service) with UID 996 and GID 996.Would write /etc/group…Would write /etc/gshadow…Would write /etc/passwd…Would write /etc/shadow…Run it without --dry-run to create the account (getent passwd myapp → myapp:x:996:996:myapp service:/var/lib/myapp:/usr/sbin/nologin), then systemctl restart myapp. If existing files already belong to a specific UID, put that number instead of -.
If the account is a regular user that lives only in LDAP or SSSD, sysusers.d is the wrong tool (the manual limits it to system users). If a service running as such an account fails with 217 only at boot and starts fine by hand afterwards, add After=nss-user-lookup.target as the systemd.special manual describes, without Wants=. The same manual says system users must resolve from earliest boot, so for a dedicated service account do not change the ordering; create it locally as above.
[3] With DynamicUser=yes, the second message is a name clash. The manual: "if User= is specified and the static group with the name exists, then it is required that the static user with the name already exists." This is the reproduction with only the group created:
# getent group webappwebapp:x:997:getent passwd webapp exited with status 2. Delete the group if nothing uses it; otherwise give User= a different name.
[4] For Failed to set up user namespacing, check whether the environment can create a user namespace at all. Inside a Docker container with default settings it was blocked:
# unshare --user trueunshare: unshare failed: Operation not permittedWhere it is blocked, turn it off for that service only (this removes one sandbox layer). So you do not overwrite an existing override.conf, create a new drop-in with its own name. Check the drop-ins already attached with systemctl cat myapp first and make sure the name is free.
[Service]PrivateUsers=no# systemctl daemon-reload# systemctl restart myappWhen options such as PrivateTmp= turn it on implicitly in a user service, the source logs the failure with "ignoring" and carries on; only an explicit PrivateUsers= ends in 217.
[5] Failed to change UID to means the UID switch itself was refused. The common place where systemd runs without privileges is systemctl --user for a non-root user, and the manual says the only valid User= there "is the same user the user's service manager is running as". Remove User= or move the unit to a system service. Because the source changes groups first, this case may end with 216/GROUP before it reaches 217.
For other codes see 200/CHDIR and 203/EXEC; for the general order, debugging a failed service.
Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.