Hosting Tutorial & Guide

Regain Access When You Are Locked out of WordPress Admin

updated on Dec 28, 2015
Regain Access When You Are Locked out of WordPress Admin Unexpected issues could happen now and then when hosting a WordPress blog. A bad luck is that you may be locked out of the WordPress admin area due to a hack or a mistake that was made unconsciously.

We have seen many beginners stuck with this problem and knowing nothing to do because they have lost control of the entire site. Since there are many causes that could lead to the problem, we have concluded the most possible issues in below.

If you are experiencing the disaster of lockout, you should be able to find a solution and regain access to your WordPress site soon.

Issue #1: Incorrect Admin Password

There is a case that you receive a warning message from WordPress that the password for the admin username you enter is incorrect although you used the same login credentials without any problem on the previous day. This situation usually occurs when a website is hacked or a plugin causes troubles.

If you cannot log into your WordPress site due to incorrect password, try resetting the password with the following methods.

Solution A: Reset password with the lost password link

On the login page, you would probably see a "lost your password" link. Clicking on the link, you will be asked to enter your username or email address. Then, WordPress sends you a link which you can follow to reset the password.

Lost Password

This is the easiest solution. However, it may not work if your site has been hacked and the profile was changed by the hacker. Entering your username might get you nothing in the inbox, and if you put in your email address, WordPress might say the email is invalid.

Solution B: Reset password with phpMyAdmin

This solution is a little bit more effective yet more advanced. If you have phpMyAdmin access to the database, you can reset the admin password by following these steps.

Firstly, use phpMyAdmin to connect to your WordPress database. If you host multiple sites on one account and have forgotten the database name, then find it in the wp-config.php file.

WordPress Database

In the list of database tables, find wp_users and click on the "Browse" link.

Browse Users

Find you username under the user_login column and click on the "Edit" link.

Edit User

Now you will see the following fields.

User Configuration

In the screenshot above, you can see user_pass under the "ID" column. What you need to do is to select MD5 in the dropdown under the "Function" column, and then enter the new password you'd like to use in the text field under the "Value" column. Click on the "Go" button on the bottom of the page, and you will be able to log into your WordPress site with your username and the new password.

Solution C: Reset password in the functions.php file

If you have access to the website files through file manager or an FTP client, you can also download the functions.php file of the theme you are using, and then add the code below to it to reset the password. The code should be placed at the beginning of the file right after the first opening <php> tag.

wp_set_password( 'newpassword', 1 );

Remember to replace "newpassword" with the password you want to use. Besides, "1" refers to your user ID which can be found in the wp_users table discussed before.

After uploading the file to your site, you should be able to log into your site. If the login succeeds, you need to modify the funtions.php file again and remove the code added before.

If password reset does not enable you to regain access, you can also try the following methods to resolve the password issue.
  • Access your site with FTP or file manager, delete .htaccess and the theme directory, then create a new theme directory and download a fresh copy of a default WordPress theme. Remember that this should only be done when you have backed up your site.
  • Disable the plugin which you use to customize the login page. The steps for doing this are included in Issue #5.

Issue #2: Database Connection Error

This is a horrible error that is commonly seen. When it happens, you would see the message "Error establishing a database connection" across your WordPress site, and all site contents are gone. Also, you might not be able to access the backend of your site.

Database Connection Error

There are many reasons for the error. For example,
  • Your hosting server is experiencing issues.
  • The database is corrupted.
  • Some of the WordPress core files are corrupted.
  • The database name, username, password or hostname is incorrect.
If you are suffering from this error and do not know which is your case, follow this guide which includes solutions for each possible reason.

Issue #3: WordPress White Screen

White screen is among the most annoying problems because it gets you locked out of the WordPress admin while not showing any clue of what is wrong. The problem may affect the backend of your site only, or even the entire site. As the causes of vary, you can try the following solutions to have the issue fixed.
  • Increase the PHP memory of your WordPress site.
  • Deactivate all plugins. After regaining access, you can enable the plugins one by one to see whether any plugin is exhausting the memory.
  • Back up your theme directory, delete the directory from your server, and then download a default theme. If the default theme fixes the issue, you should check the functions.php file of your custom theme to find out what is wrong in it.
A more detailed tutorial for fixing the white screen issue is included in this post.

Issue #4: PHP Errors Due to Code Issues

If you visit your site, no matter the frontend or the login page, and see a message similar to the following screenshot, your site is having a PHP error. Such an error is usually caused by the code you added in the functions.php file recently. It is probable that you have pasted some bad code or made a mistake while pasting code in the file.

PHP Error

If you can remember which theme file and which line of code you have modified, then the solution is simple. Just download the file from your server, revert the changes (delete the code you added), and then upload the file.

What if you have forgotten the changes? Then you need to reach a person who knows about coding for help. Or you can also change the theme you use. To prevent such errors in the future, you are suggested to learn some basic coding skills, or you'd better not make changes to the functions.php file easily.

Issue #5: Other Plugin Problems

Plugins are great for making blogging easier. However, they can also cause many unexpected troubles that lock you out of the WordPress admin area. For example, some plugins come with lockout features which are good for WordPress security, but the features may also lock you out. Besides, as discussed above, if a plugin consumes too much memory, you can also be locked out.

If you suspect that a plugin is the source of the trouble, you can try disabling all the plugins on your site without accessing the backend admin area. Below are the simple steps to do this.
  1. Access you website files with FTP and find the "plugins" folder in /wp-conten/.
  2. Rename the folder to anything else such as "plugins_disable".
If this fixes the problem and helps you regain access, you should log into the admin dashboard and then take the following steps to find out the "bad" plugin.
  1. Use FTP to rename the plugin folder back to "plugins".
  2. In the WordPress dashboard, go to "Plugins".
  3. Activate the plugins one by one until the lockout issue appears again. Now you know which the problematic plugin is.
  4. Rename the plugin folder with FTP to disable all plugins, log into your site, and activate all other plugins that are good to use.
  5. Update or delete the problematic plugin.

Not in Any of These Cases?

Having tried all the solutions offered in this tutorial but still cannot access the admin area? You should now try restoring your WordPress site if you are sure that there is a clean backup which works properly. If you do not have one, then you'd better ask a developer to check the lockout problem for you.