HTTP Error 503. The service is unavailable
Web servers such as LiteSpeed and Apache use various codes to tell browsers about responses. For example, if the webserver replies back with HTTP code 200, it means that everything is fine and the response generation was successful. There are many other response codes, but today we will discuss HTTP Error 503, and when this usually happens you get the following error on your browser: HTTP Error 503. The service is unavailable.
If you are not the administrator of the site, there is nothing much you can do as mostly this error indicates that there is something wrong on the server-side. You can either refresh the page, visit later or better notify an administrator of the site. However, if you are the administrator of the site, you can do much to figure out what is wrong and there are various reasons and ways to fix this error. There are multiple web servers, each may give you a slightly different error message, such as:
- 503 Error
- Http/1.1 Service Unavailable
- 503 Service Temporarily Available
- 503 Service Unavailable
- HTTP Error 503
- Service Unavailable – DNS Failure
- Error 503 Service Unavailable
Usually, the main thing to look for is error code which is HTTP error code 503. Today we will see how we can discuss various reasons and respective ways to fix the issue.
Server Side Issue
Before deep-diving into various reasons as to why this could happen, I would again like to mention that this is a server-side issue. All errors in the 5xx range are considered errors on the server side including 503 Service Unavailable Error. However, do keep in mind that 503 error means the server was able to process your web request and it was functioning properly but it chooses to return 503 error code because due to some problem/issue server is not able to process this request the way it should have.
Refresh the page
Some times you will get the following error
503 Service Unavailable – The server is temporarily busy, try again later!
It may really be a temporary error as the error message says, so wait some time and refresh the page. This can happen to high traffic sites, where enough resources are not available to handle the request. On the user end, be careful if you are seeing this error on the payment related pages, and make sure you won’t get charged twice.
Using our Apache as Backend Feature
If you are our customer and using our Apache as Backend feature, there is a chance that Apache is down. In this case frontend server which is OpenLiteSpeed, will give you a 503 error, as it is failed to connect to Apache. See if Apache is running
systemctl status httpd
If Apache service is not running, you can start with
systemctl start httpd
And see if your issue is resolved.
PHP FPM is down
If you get something like (Assuming you are using our Apache as backend feature or your stack includes PHP-FPM)
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
This means your PHP-FPM service is down. You can start php-fpm using
systemctl start php-fpm
In case you are our customer, there are multiple PHP-FPMs are available for different PHP versions and their respective commands are:
systemctl start php54-php-fpm
systemctl start php55-php-fpm
systemctl start php56-php-fpm
systemctl start php70-php-fpm
systemctl start php71-php-fpm
systemctl start php72-php-fpm
systemctl start php73-php-fpm
Check various log files
If your issues are still not resolved, you can start to check various log files. In the case of CyberPanel and LiteSpeed (OpenLiteSpeed), log files to check are:
In the case of Apache
You can do an efficient search of log files using the grep command such as:
cat log_file_path | grep error
cat log_file_path | grep notice
This command will make sure that you only get the most relevant information, otherwise, you may also get info level messages in your log files and they are not relevant in this case.
503 Errors due to PHP Malfunction
Most of the time 503 errors can come due to a problem in your PHP code, or either PHP-FPM/LSPHP are not able to produce response thus server started giving you 503 error. It is always recommended to first create a phpinfo page and see if your PHP side is working fine. If you can see the phpinfo page, you can move forward to further debug the cause, otherwise, make sure LSPHP is working fine and external application is created properly or PHP-FPM is up and running.
Disable PHP OPCode Caching (xCache, ACP or eAccelerator)
On a default install of CyberPanel (OpenLiteSpeed or LiteSpeed Enterprise), OPCode caching is enabled. Sometimes different sorts of opcode caching can have compatibility issues with LSPHP (PHP). So if you are getting HTTP Error 503 Error better try to disable opcode caching. On CyberPanel you first need to find out which PHP version is used by your site. To find out your PHP version on CyberPanel run the following command
cat /usr/local/lsws/conf/vhosts/yourdomain.com/vhost.conf | grep php
For example, the PHP version of your site is 7.2. Go to the configurations directory of PHP 7.2 and disable opcode caching.
mv 10-opcache.ini 10-opcache.ini.bak
systemctl restart lsws
This will disable OPCode caching. If you are not on CyberPanel, you need to find the php.ini file for your PHP and disable OPCode caching. Usually, php.ini location is disclosed in phpinfo page. If your issue is still not resolved, you can move on to the next step.
No space left on /tmp
Some web application use /tmp directory to store temporary files (session data etc). If /tmp is full you can get HTTP Error 503 Error. Use the following commands to inspect /tmp directory space
PHP memory_limit reached
memory_limit is a php directive that specifies how much memory a PHP script is allowed to allocate. Sometimes your application might be exceeding this limit, thus failed to produce response for the web server resulting in HTTP Error 503 Error. As explained above, first find out the PHP version used by your site. Then you can directly increase memory_limit from CyberPanel interface.
Login to your CyberPanel Dashboard then from left sidebar PHP -> Edit PHP Configs
- Select PHP version to change the value of memory_limit directive.
- Set the new value of the directive.
Finally, scroll down and click Save Changes.
max_execution_time is similar to memory_limit. So if your PHP script exits early without producing response again you will get the same error. You can follow the same procedure as described above to fix max_execution_time as well. Make sure to set it to a high enough value so that your script is properly executed.
We’ve pretty much discussed all the possible causes of “HTTP Error 503. The service is unavailable”. However, we recommend moving your sites to CyberPanel, because CyberPanel use LiteSpeed servers. This means in low-cost VPS you can host more sites, and using LSCache WordPress plugin you can avoid many such errors including HTTP Error 503. Because if your pages are cached, PHP engine is not used, thus giving other applications more resources to run. So in a low cost server you can run multiple sites at super fast speed and avoid such errors. You can learn in our OpenLiteSpeed vs NGINX comparision post as to why you would use CyberPanel and OpenLiteSpeed.
You can also get our managed vps and let us do this for you. We offer 3 days trial (no credit card required, plus free migration and fully managed support)
I was facing the same issue, but thanks for the help. Subscribed your blog too.
Pingback: [Solved] HTTP Error 503. The service is unavailable | - FindMaza