Blog Post

Apps on Azure Blog
2 MIN READ

WordPress: Error establishing a database connection

Tony_Ju's avatar
Tony_Ju
Icon for Microsoft rankMicrosoft
Oct 10, 2022

As PHP will only be supported on App Service on Linux after November 28, 2022. We will only discuss wordpress on Linux App service in this blog.

 

Sometimes, we may encounter the following error when accessing wordpress website.

 

 

It is very easy to understand that there is something wrong with the connection between the website and database. But how can we find more detailed information regarding this error?

 

We can enable WordPress debugging mode to check the detailed error message. The steps are as below.

 

1.Login to the newui of the scm site.(https://{sitename}.scm.azurewebsites.net/newui)

2.Click File Manager and find the wp-config.php file under site/wwwroot folder.

 

  

3.Change "define( 'WP_DEBUG', false);" to "define( 'WP_DEBUG', true );" in wp-config.php file. We can edit it directly from the newui portal.

 

With this change, you can try to access the wordpress site again without restarting the app service. You will see the detailed error message when accessing the website.

 

You may see below possible error messages. I added some suggestions for each kind of error for your reference.

 

Error 1: mysqli_real_connect(): (HY000/1045): Access denied for user 'gyomnlmsxk1'@'10.0.0.254' (using password: YES) in /home/site/wwwroot/wp-includes/wp-db.php on line 1753

         Access denied for user 'gyomnlmsxk1'@'10.0.0.254' (using password: YES)

Suggestion: Check if the credential is correct.

 

Error 2: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /home/site/wwwroot/wp-includes/wp-db.php on line 1753

Suggestion: Check if the server url is correct. If the server url is correct, check if there is any network limitation between website and database.

 

Error 3: Unknown database 'tonywordpr_83b28fe8295b4846ef6d475eecee129_database'

Suggestion: Check if the database name is correct.

 

Updated Oct 11, 2022
Version 3.0
No CommentsBe the first to comment