cannot login to wordpress admin
Can’t login due to redirect loop
If you have multiple WordPress installs on your server you may come across redirect loops. Once you’ve increased the number of your multisite installs beyond one, then you’re likely to be unable to login as you’ll get stuck in a redirect loop. That is, every time you try to login, you’re returned to the login screen.
Why Does This Happen?
Basically, each version of WordPress, regardless of its domain or subdomain, maps to a single IP address. In this case,
When a request comes into the server, part of the request includes the domain. A domain is associated with an IP address. When a cookie is created, it includes the name, some sensitive content, and then the path. As such, when you attempt to login to a WordPress installation on a different domain (but on the same IP), the cookie is essentially invalid.
Sure, clearing the cookies will do the trick, but users shouldn’t have to do that. Additionally, not everyone will see this problem occur, but if you’re in the business of managing a multisite installation in a shared environment, then you’re likely to see it.
The code below will ensure that WordPress is clearing the cookie for the given domain of the multisite thus allowing the login process to set it correctly.
wp-config.php file, add the following lines of code:
Can’t login due to changed url
If you accidently changed your url (Ex. From http://www.examplesite.com to http://examplesite.com/test) in your admin settings you can use this to fix it:
<?php update_option('siteurl','http://www.examplesite.com'; ?>
in your theme’s functions.php.
Other login problems
- Other ways to fix login problems is to clear your browser cache and/or cookies.
- Disable all of your WordPress Plugins, either through the admin panel or by removing them from the /wp-content/plugins/ folder, so they will not be recognized by the program.
- Alternatively, you can rename the plugins folder to something else temporarily to something like /wp-content/pluginsXX/ and they will not be recognized. Rename the folder back to /wp-content/plugins/ once the base WordPress installation has been recovered.
- Deactivate your theme
- Rename the active theme folder (in wp-content/themes) by using FTP. Once renamed, WordPress will revert to using the WordPress Twenty Fourteen theme. When finally logged in, change to a different theme.
- To find out what caused problem in the theme, upload and run this code when the theme is active:
- <?php ini_set(‘display_errors’,’1′); ini_set(‘display_startup_errors’,’1′); error_reporting (E_ALL);include(‘index.php’); ?>
- New Login File
- Sometimes the wp-login.php file may have been corrupted or uploaded incorrectly.
- Delete wp-login.php off of your server and upload a new copy from a fresh WordPress download. Remember, overwriting file via FTP can lead to incomplete transfers.
- Edit wp-login.php as follows
- Go to the case retrievepassword section, found under this comment:
// redefining user_login ensures we return the right case in the email
$user_login = $user_data["user_login"];
$user_login = $user_data->user_login;
- Edit Users Table
- Access your site’s phpMyAdmin and edit the database carefully.
- Open the WordPress database.
- Click on the users table in the left menu (default is wp_users, or yourprefix_users if you defined a different table prefix.)
Click on the EDIT button next to the admin user.
Delete whatever is in the password field.
Enter your desired password.
From the Function drop-down list, choose MD5.
Save the info in the database.
Log in to WordPress using “admin” and the password you used.
In the case of newer versions of WordPress, the password is double hashed, but as long as you md5 the password, it will complete the hash (it upgrades your password for you).