Error 503 often appears unexpectedly. To monitor the site and receive service availability information via email or other channels, consider using the WEDOS OnLine service.
In this article, you will learn:
Error 503 Service temporarily unavailable
You can recognize Error 503 by the large Service Temporarily Unavailable heading at the top of the page. Below the heading you will find a more detailed description of the error, as well as a link to this article.
You can encounter Error 503 Service Temporarily Unavailable on any website that uses PHP or similar technologies to function. The server is running, but still not responding to new requests. The cause of this behavior is usually reaching the limits of some web hosting parameters.
Troubleshooting Error 503
Each NoLimit Webhosting has up to 25 PHP processes reserved on our server (7 for LowCost, 30 for Extra) that can run at the same time. This means that the processor can process a maximum of that many PHP requests at one time. Requests that the processor cannot handle due to the time requirement are queued up and waiting to be served. If they aren’t assigned a free PHP process in the given time (called timeout), the page will return Error 503.
Under normal circumstances, 25 PHP processes is enough – if your website is properly optimized, you should not encounter this problem.
The Error 503 is most often caused by:
- an attack on the web server,
- bad web or database optimization,
- insufficient hosting service parameters,
- stuck PHP process.
Attack on the Web Server
A common cause of Error 503 is attacks or other forms of overloading your website with requests that exhaust processes and block real users from accessing the website. In this situation, the error usually appears at different times, lasting from units to tens of minutes.
You can verify this cause by logging according to the Webhosting – Logging instructions, utilizing both Accesslog and Errorlog.
- In the Accesslog, you will find a list of accesses to your website, including specific addresses. Nonsense addresses or parameters (listed in the address after the ? character) are a common sign of an attack.
- in the Errorlog, you will find the times during which the Error 503 occurred. If these times coincide with access peaks in the Accesslog caused by suspicious activity, the error was most likely caused by an attack.
WEDOS is currently intensively developing top protection against attacks – the WEDOS Global network. If you observe a frequent occurrence of Error 503 due to attacks, consider using this protection on your domain.
Web and Database Optimization
If the website is not optimized, even regular traffic can often lead to congestion. The error appears either during peak traffic or maintenance; it typically lasts units to tens of minutes.
Common causes of Error 503 and their solutions include:
- Badly optimized PHP app: The app does not send its requests to the processor efficiently. If you are using a content management system, find out if it allows caching. If so, turn it on. This significantly shortens the script execution time, reduces the number of SQL queries to the database and speeds up your pages. You can find more information in the article Webhosting – Cache and Proxy.
- Large number of database entries: The app records every visitor access or similar extensive data sets in the database. Consider what data you really need and adjust either the application or the hosting service accordingly.
- Suboptimal database design: The app has improperly configured database tables. PHP then waits a very long time for the results of SQL queries. Research more suitable indexing options and other ways to optimize.
- PHP app connects to an unavailable external source: The app is downloading external data, but the target server is not responding, or is overloaded. If you experience this problem frequently, consider changing your external data source.
- Cron script takes too long to execute: If you have a large number of crons, or the crons run for a long time, they can block the PHP processes available to your website. Think about which crons your application really needs, how often do they have to run, and how you can optimize them.
- Download via PHP: The app mediates large file downloads using a PHP script, which is then occupied during the entire donwload process. Download files by redirecting directly to the file’s URL address.
- A large number of files in suboptimal directory structure: The app contains thousands of items in one directory. Sort the files into several directories.
The Error 503 may not be related to current traffic or changes on the site at all. You often encounter loading some data from a slow or unavailable external source, or running a cron that takes a long time to load, update, perform maintenance, etc. Also, a large number of complex requests, usually searches in large databases, can coincide and cause the error.
Upgrade Hosting Service
If you are unable to find a way to optimize the website, you can adapt the performance of the service to its requirements. Consider these options:
- Change Webhosting plan: You can upgrade the Webhosting plan from LowCost to NoLimit, or from NoLimit to Extra. You can find a Webhosting plan performance comparison at this link. Instructions for changing the plan can be found in the article Webhosting – Change Plan.
- Change service: If the performance of shared web hosting is not enough for your app, but you do not want to deal with managing a virtual server, consider migrating the application to the WMS service.
- Separating aliases and subdomains. Webhosting aliases and subdomains share the same server resources. If traffic on one or more aliases or subdomains causes the Error 503, consider setting up separate hosting for that domain or subdomain.
Stuck PHP Process
In rare cases, Error 503 can also be caused by a stuck PHP process. If you observe Error 503 consistently for several tens of minutes to hours and clearing the browser cache does not help either (for example using the keyboard shortcut Ctrl+Shift+R), restart PHP on your Webhosting service:
- Log into the customer administration panel.
- In the navigation bar, select Web & Email Hosting Webhosting.
- Choose the webhosting to restart PHP for.
- In the left menu, click PHP Configuration.
- Change the PHP version to an adjacent one (e.g. PHP 7.4 -> 7.3, or 8.0 -> 8.1)
- Click the Edit button.
- Wait half an hour for the PHP version change to take place. Then restore the original version back in the same way.
If the 503 error persists after such a restart, it is probably caused by something other than a stuck process.
FAQ
Question: Is Error 503 specific to WEDOS servers?
Answer: You can encounter a 503 error on any web server. When you are looking for suitable hosting for your application, first familiarize yourself with its requirements, and then adjust your own demand accordingly. In addition to available space for files and database, pay attention to RAM and CPU parameters. Keep in mind that the price of the service goes hand in hand with the performance.
Question: I have completely shut down the entire site but I keep seeing Error 503, why is it?
Answer: Try clearing your browser cache (for example, with the keyboard shortcut Ctrl+Shift+R). If that doesn’t help, try restarting PHP as described in the Stuck PHP Process chapter.