“500 Internal Server Error” after updating a WordPress site to PHP 7.3

This post was most recently updated on April 28th, 2019.

Reading Time: 5 minutes.

Now for something totally different – for a change, I got to fix an issue with my own blog, so I had the chance to delve into PHP and WordPress configurations… :)

PHP is an ever-evolving language – even if it might not always feel that way. The old workhorse has been powering most of the internet for a couple of decades, and weirdly enough, doesn’t really show signs of going anywhere.

A huge part of the success story has been the fact that WordPress, the most popular website platform in the world, is built on it.

With WordPress 5.1 (just published), the platform now complains if you’re using old versions of PHP. That’s a great move if you ask me – even though WordPress works just fine with older versions, it’s safer and faster to run later and up-to-date versions. Currently, it’ll complain about anything below 5.6, but hopefully that version will be bumped up as soon as possible. See below for the warning in action:

WordPress 5.1 now bugs you to update your PHP version if you're running and old and insecure version.
WordPress 5.1 now bugs you to update your PHP version if you’re running and old and insecure version. (read more)

Anyway – if you’re running anything less than PHP 7.2, you should probably update, as all the earlier versions are either unsupported or only getting security patches.

Upgrading from PHP 5.6

PHP 5 was released in 2004(!), and 5.6 was the last version of PHP 5 that was still recently supported. It reached its end-of-life at the beginning of 2019, so it was a good time to upgrade.

Looking at the options today, 7.0 is already deprecated, so I’m left with 7.1, 7.2 and 7.3, the last 2 of which are still completely supported. 7.1 only receives security fixes currently.

Each new version brings new improvements and features, but also could deprecate old features or even remove modules or functions that your current solutions rely on… So before choosing the correct version, it’s wise to check any compatibility information your current solution providers offer.

My primary interest in this particular case was WordPress, as that’s the platform my current blog is hosted on. WordPress has compatibly info available here: https://wordpress.org/about/requirements/

From PHP 5.6 straight to PHP 7.3

Well, that’s simple and straightforward. At the time of writing, PHP 7.3 is the recommendation for WordPress, but versions all the way back to early 2000s are supported.

Since WordPress didn’t seem to have any issues, I started looking at my plugins – but most of them don’t have much info available in regards of PHP compatibility, so soon enough I gave up. Post-upgrade, I’d always have the option to downgrade.

So I went forward with the upgrade, jumping directly to PHP 7.3. When hitting refresh a few times afterwards, I was faced with this error:

PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect()

Ouch. Sounds like something very elementary is now broken. If WordPress can’t access the database hosting its data, there isn’t much it’s going to do.

So, I started digging. This is what I found in the error_log:

[07-Jan-2019 20:36:35 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in [site]public_html/[site]/wp-includes/wp-db.php:1564
Stack trace:
#0 [site]public_html/[site]/wp-includes/wp-db.php(592): wpdb->db_connect()
#1 [site]public_html/[site]/wp-includes/load.php(409): wpdb->__construct('...', '...', '...', '...')
#2 [site]public_html/[site]/wp-settings.php(106): require_wp_db()
#3 [site]public_html/[site]/wp-config.php(91): require_once('[site]...')
#4 [site]public_html/[site]/wp-load.php(37): require_once('[site]...')
#5 [site]public_html/[site]/wp-blog-header.php(13): require_once('[site]...')
#6 [site]public_html/[site]/index.php(17): require('[site]...')
#7 {main}
  thrown in [site]public_html/[site]/wp-includes/wp-db.php on line 1564

So mysql_connect() is broken. Why?

Well, that might be because that function was already deprecated in PHP 5.5 and removed in PHP 7.0.

This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide.


I tested PHP 7.2 as well, and to my surprise it worked. I didn’t think it should, though… The PHP team already removed the command in version 7.0! But comparing the default configuration for the PHP extensions revealed the issue:

For PHP 7.2, the default extensions are different. My guess is that for whatever reasons, 7.3 didn’t have the module overwriting the deprecated and removed function available by default whereas 7.2 did.

Since the PHP extension configuration varies by host and server, you could encounter the same 500 error after any PHP update (more or less). I’m fairly certain, that at least updates from PHP 5 to PHP 7.1, PHP 7.2 or 7.3 could cause this issue on a lot of different hosting companies.

How to get WordPress to work with PHP 7?

If you still want to continue using your WordPress installation (I mean, you could take this as a sign, right?) you should be able to do that. After comparison, I narrowed the missing extension down to nd_mysqli.

Just navigate to your web hosting panel and enable the module called nd_mysqli. There’s a fair chance your extension name could be different, though – web hosting providers are different.

Enabling the extension nd_mysqli to get mysql_connect() to work.
Enabling the extension nd_mysqli to get mysql_connect() to work.

After this, your site should load just fine again! Fixed the issue for me at the very least.

And if you’re in luck, you’ll see performance gains from the upgrade – at the very least, you’ll be more secure in the future.

The exact configuration of different extensions is of course different for different hosting providers. You might not need to take these steps at all, or the extension might be named differently. But I thought documenting them is useful anyway! :)

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments

Thank you so much for posting this, I got the 500 error after upgrading PHP to 7.3, a quick tick in the mysqli box got the sites back up and running again, you are a life saver.


Thank you for the help.
In my case i just had to re-check the “mysqli” in the cPaner-> PHP Versions selector which was by default unchecked after setting PHP to vers. 7.3

best regards,

Andrzej Rodziewicz

Thank you for a brilliant post. My host had no idea what to suggest. I enabled these modules in 7.3 and all my sites came back up!