In this article I will show you how to troubleshoot on this issue: “Azure App Service PHP application returning HTTP Error 503 – The service is unavailable” to determine the reason behind the above problem and provide suitable recommendations for the same.
During this downtime I was unable to reach out the SCM / Kudu Console but I could connect via FTP client.
Before we start troubleshooting this issue consider the following:
- First of all, enable PHP error log and shared the php_errors.log file from location d:\home\LogFiles
- You can enable PHP error log in .user.ini file by adding log_errors=On line
- By default, PHP Errors are located at d:\home\LogFiles\php_errors.log
Note: Reference to enable PHP error log: https://blogs.msdn.microsoft.com/azureossds/2015/10/09/logging-php-errors-in-wordpress-2/
You could also enable “Diagnose and solve problems” option in the App Service blade, this will give you a quick assessment on your web app:
Diagnose and solve problems will also provide you with the details of the errors you might have in you web app:
Troubleshooting: Azure App Service PHP application returning HTTP Error 503
Connect to your site via ftp client and rename the plugins name for example “plugins-deactivated” . This will deactivate all the plugins. stop/start your webapp.
Confirm that there was no Azure App Service platform issue observed during this time:
- As of writing time I was using S3 Standard Large Azure App Service plan.
- Try scaling up from S3 to S2 Standard which you will get the working Virtual machine.
- Once everything starts working you can scale up back to S3 Standard.
For this specific case, the EventLogs for the Web App showed a repeating configuration failure:
Config section 'system.webServer/runtime' already defined. Sections must only appear once per config file.</Data><Data>\\?\ C:\DWASFiles\Sites\wikiazure\Config\applicationhost.config
This error was preventing the Web App processes from starting up, thus the 503 service unavailable.
You should be able to find this error under “\LogFiles\EventLog.xml” if you FTP connect to the Web App itself (remember that SCM site was unreachable).
Check if you are using the “Composer” site extension at all, or any “applicationHost.xdt” file
Also check any Web.config files for duplicate “system.webServer/runtime” sections.
Then go to your web app settings and enable the “WEBSITE_PRIVATE_EXTENSIONS” with value = “0” then stop/start the web app.
Doing some digging on this and found a few previous reports of this same error message “Config section ‘system.webServer/runtime’ already defined”, one example is this forum post:
In each case the issue seems to be related to a malfunctioning Site Extension, check if you have anything related to Application Insights/New Relic/Gulp extension on your Web App.
If you FTP connect to the app, you can check if any files exist under D:\home\site\siteextensions\ or D:\home\SiteExtensions\.
In this case, I was using this extensions:
Are you actually using either the New Relic/Application Insights extensions at all on this site? According to previous history the New Relic extension is incompatible with PHP sites, try removing all the New Relic files from:
This site extension is known to have configuration files which can impact the site.
You should also be able to remove New Relic from the “Extensions tab” of the Web App in the Azure portal. Delete the New Relic extension, restart the Web App:
Azure App Service PHP application returning HTTP Error 503
Found that the Web App was repeatedly crashing with a config error in the EventLog.xml:
"Config section 'system.webServer/runtime' already defined. Sections must only appear once per config file".
This error was caused by incompatible New Relic extension used with PHP apps in App Service. Resolved the issue by manually deleting the New Relic files via FTP, restarting, and the site is online again 🙂