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.
Figure: 2
Then click CMD or PowerShell that opens a console similar to that shown in Figure 3. I have opened CMD below.
Figure: 3
Now, navigate to wwwroot folder.
Figure: 4
Then trace down ‘wp-config.php file as seen in figure 5.
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.
Figure: 6
We need to ensure that correct values are set in the red boxes as per I have highlighted below in Figure 7.
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.
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!