doc/user/profile/account/delete_account.md
{{< details >}}
{{< /details >}}
Users can be deleted from a GitLab instance, either by:
[!note] Deleting a user deletes all projects in that user namespace.
{{< details >}}
{{< /details >}}
{{< history >}}
delay_delete_own_user. Enabled by default on GitLab.com.{{< /history >}}
[!note] On GitLab Self-Managed, this feature is disabled by default. Use the application settings API to enable the
delay_user_account_self_deletionsetting for the instance.
You can schedule your account for deletion. When you delete your account, it enters a pending deletion state. Generally, deletions complete in one or two hours but can take up to seven days for accounts that are associated with comments, issues, merge requests, notes, or snippets.
While your account is pending deletion:
[!note] After the account is deleted, any user can create a user account with the same username. If another user takes the username, you cannot reclaim it.
To delete your own account:
If you cannot delete your account on GitLab.com, submit a personal data request to remove your account and data from GitLab.
{{< details >}}
{{< /details >}}
Prerequisites:
To delete a user:
[!warning] Using the Delete user and contributions option may result in removing more data than intended. See associated records for additional details.
When deleting users, you can either:
@ghost1).In both cases, commits retain user information and therefore data integrity within a Git repository.
An alternative to deleting is blocking a user.
When a user is deleted from an abuse report or spam log, these associated records are always removed.
The deleting associated records option can be requested in the API as well as the Admin area.
[!warning] User approvals are associated with a user ID. Other user contributions do not have an associated user ID. When you delete a user and their contributions are moved to a ghost user, the approval contributions refer to a missing or invalid user ID. Instead of deleting users, consider blocking, banning, or deactivating them.
{{< details >}}
{{< /details >}}
[!warning] The root account is the most privileged account on the system. Deleting the root account might result in losing access to the instance Admin area if there is no other administrator available on the instance.
You can delete the root account using either the UI or the GitLab Rails console.
Before you delete the root account:
Prerequisites:
To delete the root account:
[!warning] Commands that change data can cause damage if not run correctly or under the right conditions. Always run commands in a test environment first and have a backup instance ready to restore.
Prerequisites:
To delete the root account, in the Rails console:
Give another existing user administrator access:
user = User.find(username: 'Username') # or use User.find_by(email: 'email@example.com') to find by email
user.admin = true
user.save!
This ensures that you maintain administrator access to the instance whilst mitigating the risks associated with deleting the root account.
To delete the root account, do either of the following:
Block the root account:
# This needs to be a current admin user
current_user = User.find(username: 'Username')
# This is the root user to block
user = User.find(username: 'Username')
::Users::BlockService.new(current_user).execute(user)
Deactivate the root user:
# This needs to be a current admin user
current_user = User.find(username: 'Username')
# This is the root user to deactivate
user = User.find(username: 'Username')
::Users::DeactivateService.new(current_user, skip_authorization: true).execute(user)
There is a known issue that results in users not being deleted, and the following error generated:
ERROR: null value in column "user_id" violates not-null constraint
The error can be found in the PostgreSQL log and in the Retries section of the background jobs view in the Admin area.
If the user being deleted used the iterations feature, such as adding an issue to an iteration, you must use the workaround documented in the issue to delete the user.