WordPress: Error establishing a database connection
Published Oct 10 2022 01:28 AM 6,058 Views

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'@'' (using password: YES) in /home/site/wwwroot/wp-includes/wp-db.php on line 1753

         Access denied for user 'gyomnlmsxk1'@'' (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.


Version history
Last update:
‎Oct 10 2022 05:55 PM
Updated by: