gravitational/teleport · warning
User logged in error
Error message
User logged in error
What it means
ErrUserLoggedIn is a public sentinel error from host user management. It wraps the result of host.UserDel when the OS reports the exit code UserLoggedInExit, meaning the Unix user cannot be deleted because a login session is active. User management maps this to skip deletion gracefully (e.g. the temporary insecure-drop user with an active session is left in place and removed later).
Source
Thrown at lib/srv/usermgmt.go:170
type userCloser struct {
users HostUsers
backend HostUsersBackend
username string
}
func (u *userCloser) Close() error {
teleportGroup, err := u.backend.LookupGroup(apiconstants.TeleportDropGroup)
if err != nil {
return trace.Wrap(err)
}
err = u.users.doWithUserLock(func(sl types.SemaphoreLease) error {
return trace.Wrap(u.users.DeleteUser(u.username, teleportGroup.Gid))
})
return trace.Wrap(err)
}
var ErrUserLoggedIn = errors.New("User logged in error")
type HostSudoers interface {
// WriteSudoers creates a temporary Teleport user in the TeleportDropGroup
WriteSudoers(name string, sudoers []string) error
// RemoveSudoers removes the users sudoer file
RemoveSudoers(name string) error
}
type HostSudoersNotImplemented struct{}
// WriteSudoers creates a temporary Teleport user in the TeleportDropGroup
func (*HostSudoersNotImplemented) WriteSudoers(string, []string) error {
return trace.NotImplemented("host sudoers functionality not implemented on this platform")
}
// RemoveSudoers removes the users sudoer file
func (*HostSudoersNotImplemented) RemoveSudoers(name string) error {
return trace.NotImplemented("host sudoers functionality not implemented on this platform")View on GitHub (pinned to 1283425b60)
Solutions
- No action needed: Teleport detects this and skips deletion, retrying on a later cleanup cycle
- Ensure the user's sessions are terminated before manual user removal (log out, kill lingering processes)
- Manually remove the user later with userdel once no sessions reference it
Defensive patterns
Strategy: type-guard
Validate before calling
// check active sessions before deleting
if sessionsActive(username) {
log.DebugContext(ctx, "user has active session; deferring deletion")
return nil
} Type guard
func isUserLoggedInErr(err error) bool { return errors.Is(err, ErrUserLoggedIn) } Try / catch
err := u.backend.DeleteUser(username)
if errors.Is(err, ErrUserLoggedIn) {
log.DebugContext(u.ctx, "Skipping deletion of user with an active session")
return nil
}
if err != nil { return trace.Wrap(err) } Prevention
- Treat ErrUserLoggedIn as retry-later, not fatal
- Terminate user sessions before forced deletion
- Rely on periodic cleanup to remove the user once sessions end
When it happens
Trigger: Calling DeleteUser (or the usermgmt backend delete path) with host.UserDel while the target Linux user has an active login session, yielding UserLoggedInExit which is converted to ErrUserLoggedIn.
Common situations: A user logs out but a lingering session (tmux, ssh connection, background process keeping the session) holds the account; TeleportDrop temporary user deletion while their SSH session is still open; insecure-drop cleanup racing an active session.
Related errors
- user not managed by teleport
- elevated credential activation not implemented for linux
- managed host users can not be converted to or from a static
AI-assisted analysis of gravitational/teleport@1283425b60 (2026-09-02).
Data as JSON: /api/errors/714f8c27f3da527e.
Report an issue: GitHub.