Stuck on upgrade.php in WordPress?

Sometimes, my friend’s wordpress based site is simply stuck on /wp-admin/upgrade.php?_wp_http_referer=%2Fwp-admin%2F when trying to login as admin.

The error occurs if there’s a mismatch between the version wordpress thinks it’s running according to its database and according to its config files in the file system. I don’t know why this happens, but the quick and dirty fix goes somethinglike this.

My friend uses cPanel to manage their webserver, so you may have to take a different path to getting there.

  • In cPanel, find databases -> phpMyAdmin
  • Open the primary database for your wordpress installation
    Search for a table named someting ending in _options (in my case rlBnh_options) and open it.
  • Find the row / option name called db_version and take note of the value, in my case currently 53496
  • Back in cPanel, find Files -> File management
  • In the link tree, open public_hmtl and then wp-includes
  • In this wp-includes folder, open/edit the file named version.php
  • There’s a line starting with $wp_db_version = and then a number.
  • If this number is not equal to the one you found in your database before (and if you’re reading this, I bet it isn’t), change the value in this line to the number you found before. In my case 53496. So the line reads:

$wp_db_version = 53496;

Remember the semicolon

INSTEAD OF 53496 USE THE NUMBER YOU FOUND IN YOUR DATABASE.
DO NOT USE MY EXAMPLE VERSION NUMBER OR ENTER SOME RANDOM NUMBER.

  • Save the version.php file.
  • You should be able to login now.

As I said before, my friend uses cPanel to manage their webserver, so you may have to take a different path to getting through the steps above.

You may need to use another way to interface with the database, and maybe you have to edit the file via an SSH or FTP connection.

But the TL;DR solution is, make the version number in wp-includes/version.php match the value found in your database -> *_options -> db_version.

No idea why this happens.