Hi GC,
Welcome to the Microsoft Q&A Platform!
The "Error establishing a database connection" issue in an Azure WordPress service typically means that your WordPress site is unable to connect to the database.
Ensure DB_NAME
, DB_USER
, DB_PASSWORD
, and DB_HOST
in wp-config.php
are correct
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'your_database_host');
Access wp-config.php
via Azure's App Service Editor or FTP.
In the Azure portal, navigate to the Azure Database for MySQL resource.
Verify that the database is running and has no connectivity or maintenance issues.
Go to your WordPress App Service in the Azure portal.
Click Restart under the Overview tab.
Ensure the database firewall allows connections from your App Service’s outbound IP.
Update the firewall settings if needed.
Review database and App Service metrics for CPU, memory, or storage constraints.
Upgrade the service plan if required.
Enable WordPress debugging in wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Access logs via /wp-content/debug.log
or Azure Log Stream.
Use Azure Backup or a manual backup to restore the database and files if corrupted.
https://learn.microsoft.com/en-us/azure/app-service/quickstart-wordpress
https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview
If the answer is helpful, please click ACCEPT ANSWER and kindly upvote it