Having problems logging into WordPress ? It’s a tricky area, with a seemingly endless list of problems, causes and recommendations. In my case, the “login” link would hang before even asking for a user name or password. The browser window would eventually give up saying “no response from server”. The blog was up and healthy, but logging in as admin (or any other user) was not possible.
This kind of lockout is particularly nasty because without admin access, you can’t easily alter the very settings which might be causing the problem. After rebooting the server, the client PC, the local router, restoring /usr/share/wordpress from backups, checking endless config files to no avail, I eventually found an easy fix.
Possible Causes
Many pages give suggestions for when your blog hangs after you type in the credentials. Here and here are some examples from the support forums at WordPress.org.
But what if you don’t get the login screen ? Long story short, the problem was caused by an incorrect setting of the “WordPress Address” and “Site Address” URLs normally found on the Admin page under Settings->General. Yes, one mistake here can lock you out of your own blog. It’s an astonishing booby trap, but can be fixed though mysql as follows.
First, check those settings:
root:~# mysql -u root -p Enter password: ... mysql> use wordpress Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +-----------------------+ | Tables_in_wordpress | +-----------------------+ | wp_commentmeta | | wp_comments | | wp_links | | wp_options | | wp_postmeta | | wp_posts | | wp_term_relationships | | wp_term_taxonomy | | wp_terms | | wp_usermeta | | wp_users | +-----------------------+ 11 rows in set (0.00 sec)
It’s the wp_options table we are interested in. Interrogate it as follows.
mysql> select option_name, option_value from wp_options where option_name = 'home'; +-------------+---------------------------+ | option_name | option_value | +-------------+---------------------------+ | home | https://unixetc.co.uk:8080 | +-------------+---------------------------+ 1 row in set (0.00 sec) mysql> select option_name, option_value from wp_options where option_name = 'siteurl'; +-------------+---------------------------+ | option_name | option_value | +-------------+---------------------------+ | siteurl | https://unixetc.co.uk:8080 | +-------------+---------------------------+ 1 row in set (0.00 sec)
There’s the problem. home and siteurl are both set to “https://unixetc.co.uk:8080“, whereas they should be just “https://unixetc.co.uk“. I vaguely recall messing about with port 8080 last week and must have tried these settings and forgot to put them back. I know, I know.
Fortunately, it’s easy to put back the right values with MySQL:
mysql> update wp_options set option_value = 'https://unixetc.co.uk' where option_name = 'home'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select option_name, option_value from wp_options where option_name = 'home'; +-------------+----------------------+ | option_name | option_value | +-------------+----------------------+ | home | https://unixetc.co.uk | +-------------+----------------------+ 1 row in set (0.00 sec)
and:
mysql> update wp_options set option_value = 'https://unixetc.co.uk' where option_name = 'siteurl'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select option_name, option_value from wp_options where option_name = 'siteurl'; +-------------+----------------------+ | option_name | option_value | +-------------+----------------------+ | siteurl | https://unixetc.co.uk | +-------------+----------------------+ 1 row in set (0.00 sec)
That’s it! The login page came back to life immediately. I went to the login screen (aka wp-login or wp-login.php) and was presented with the usual login dialogue. After entering the right user name and password, I was on.
Conclusion
It’s great to fix the problem through MySQL. However, WordPress should not allow a simple setting to lock out admin user. At least, the “home” and “site url” settings should appear with a big and I mean big warning.
An out-of-band or “back door” into the Admin settings should be available, a bit like “single user” or “safe” mode with operating systems. WordPress is widely used by writers, journalists and non-technical people. What’s their grasp of MySQL like ?
WordPress should at least attempt some kind of PHP error reporting. How many lines of PHP are there in wordpress ? And no error handling ? Come on man. A simple message like “site name mismatch” would have saved a lot of work.
WordPress is still pretty reliable otherwise and I would still recommend it.