2019-06-07 10:33:31 -04:00
---
2021-10-06 14:12:19 -04:00
stage: Manage
group: Access
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-06-07 10:33:31 -04:00
type: howto
---
2019-07-14 21:04:35 -04:00
2021-06-13 17:10:11 -04:00
# How to unlock a locked user from the command line **(FREE SELF)**
2018-07-18 12:06:31 -04:00
2020-03-09 14:07:59 -04:00
After ten failed login attempts a user gets in a locked state.
2019-06-07 10:33:31 -04:00
2019-07-16 03:02:20 -04:00
To unlock a locked user:
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
1. SSH into your GitLab server.
1. Start a Ruby on Rails console:
2018-07-18 12:06:31 -04:00
2020-01-30 10:09:15 -05:00
```shell
2019-07-16 03:02:20 -04:00
## For Omnibus GitLab
2020-02-28 01:09:19 -05:00
sudo gitlab-rails console -e production
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
## For installations from source
2020-04-15 05:09:46 -04:00
sudo -u git -H bundle exec rails console -e production
2019-07-16 03:02:20 -04:00
```
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
1. Find the user to unlock. You can search by email or ID.
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
```ruby
user = User.find_by(email: 'admin@local.host')
```
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
or
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
```ruby
user = User.where(id: 1).first
```
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
1. Unlock the user:
2018-07-18 12:06:31 -04:00
2019-07-16 03:02:20 -04:00
```ruby
user.unlock_access!
```
2021-01-29 16:09:34 -05:00
1. Exit the console with < kbd > Control</ kbd > +< kbd > d</ kbd >
2019-07-16 03:02:20 -04:00
The user should now be able to log in.
2019-06-07 10:33:31 -04:00
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X` .
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->