503 errors
The 503 HTTP status code means "Service Unavailable". This article aims to help developers troubleshooting 503 errors.
- 503 errors will usually be shown on screen immediately
- 503 errors often occur after code or configuration changes
- 503 errors are sometimes just printed as a "service unavailable" message, check the browser's developer tools for the response's HTTP status code to be sure this is indeed a 503 error
- 503 errors here are often rendered using a fortrabbit error page template
503 and 504 errors are two sides of the same coin. PHP-FPM (the PHP process manager here) has too much to do. 503 and 504 errors are often happening simultaneously. 503 and 504 are two sides of the same coin. PHP-FPM has too much to do. Happening at the same time. In most cases this is not a server issue, but something with your code and configuration. Performance problems are often people problems
# Check the logs
503 errors are often associated with uncontrolled termination, in many cases no PHP error logs will be written. It's anyhow worth a try. See the logs article. Maybe you can find where the application exited with which error. Compare this with your local development environment and see if it fails the same way.
# 'AH1067: Failed to read FastCGI header' Apache error
If you see the error "Failed to read FastCGI header" in the App's error log stream, there are these likely causes:
- A bug in the App's PHP code, such as a buggy WordPress plugin
- The App is using too much memory
- A bug in a PHP extension you've enabled
- When this error occurs, the response sent to the browser will be "503 Service Unavailable"
# What the error means
The error message "Failed to read FastCGI header" means that while Apache was waiting for PHP-FPM, the PHP process did not respond properly. This error does not mean there is a problem with Apache.
# Restarting PHP (workaround)
In some cases, to the the App working again, it may be enough to restart the environment from the Dashboard. If the issue is caused by buggy code, or slow queries, or 3rd party APIs, the problem is likely to happen again.
# Review your latest changes
Review your code and configuration changes. Compare this with your local development environment and see if it fails the same way. Have you ran an update recently?
# Look for errors and slow endpoints
The most common cause of these errors is buggy PHP code. You can try disabling Craft CMS or WordPress plugins, custom themes, and other custom code until you identify which code is causing the problem. If some or several scripts or endpoints of you App are slow, new connections will get backed up, ultimately resulting in PHP-FPM not being able to respond any more. If this is the case, then the solution is to optimize the slow PHP code.
# Running out of memory
If your application uses more memory than the plan allows for, the website will crash every time the limit is exceeded. environments are configured with swap to avoid crashes, but if you see more than 10-30 MB of swap usage in the dashboard, then this is a strong indicator that your app is using too much memory.
# Upgrade the plan
One solution is to upgrade your PHP plan, if possible. Otherwise, you wil have to profile the App to figure out why it's using so much memory.
# It could also be something on our side
It is also possible — although less likely - that this error is caused by a network, hardware or configuration issue on our side, your hosting provider. Please check our status page under status.fortrabbit.com if there are any ongoing maintenance windows or service issues known.
Found a tpyo?Edit