Troubleshooting DB Error in WordPress on Azure with Kudu

Recently, my blog had some unexpected downtime. I’m still unsure of why this error occurred, however, I find it worth sharing on how I was able to bring it back online. The error received looked like ‘Error establishing a database connection’.

Figure: 1

Initially, I thought this has something to do with the database, or with the database connection string. But, this case was different, still unknown but glad I have it settled now.

I host this blog in Microsoft Azure, using hosted WordPress. WordPress uses a mySql database to store content, which Azure doesn’t support, but they use a trusted third-party (ClearDB) to host for them.

So, I logged into my ClearDB instance. There’s definitely still a database, and it’s online, and I can see that it’s functional.

The database is there, but there’s an error establishing a connection to it. What would cause that? Maybe a network connectivity issue between Azure and ClearDB. I checked Azure Status – and there’s nothing there.

However, since I have somehow been able to solve this issue, let’s go about how to make it up and running.

First, login to Kudu. To access your KUDU console, using your deployment credentials, navigate to: https://merocloud.scm.azurewebsites.net/DebugConsole. Once authenticated, you should see a page similar to the one illustrated with Figure 2.

Next, Click on the Debug Console as can be seen in Figure 2.

SNAGHTML12331d46

Figure: 2

Then click CMD or PowerShell that opens a console similar to that shown in Figure 3. I have opened CMD below.

SNAGHTML1233d25e

Figure: 3

Now, navigate to wwwroot folder.

SNAGHTML123413bc

Figure: 4

Then trace down ‘wp-config.php file as seen in figure 5.

SNAGHTML12345c6d

Figure: 5

When you click on the edit option for ‘wp-config.php file, you will discover that the required DB settings have changed to random as can be seen in Figure 6.

SNAGHTML1239fe52

Figure: 6

We need to ensure that correct values are set in the red boxes as per I have highlighted below in Figure 7.

SNAGHTML12361604

Figure: 7

Once updated, save the settings and navigate to your Web App URL (for me this is: https://merocloud.com) to confirm whether the site is up.

Here we go! It’s up & running in my case. Smile 

If you have faced similar issue before and you understand why this is happening, would appreciate if you could share your understanding in the comment section below.

I hope you enjoyed going thru this blog. Hope you will come back!

Thanks for the visit! Smile 

 

Public Cloud Consultant | Microsoft MVP | Solutions Specialist (Azure) | Azure Certified | Microsoft Certified Trainer A decade more experience working across various Microsoft products, programs, projects & technologies. Experience leading CoE (Centers of Excellence) for Azure, Microsoft 365, Dynamics 365 & Power Platform among others. Enabler in customer's hybrid cloud, cloud assessment, migration and modernization journey.

Leave a Reply

Your email address will not be published. Required fields are marked *