Today one server was having some strange LitSpeed 503 error on one of their websites. The message was clear: “503 service unavailable”, “the server is temporarily busy, try again later”.
What causes this 503 error on LiteSpeed web server?
The first thing you have to do is to check the litespeed logs. You can do this by moving to
Admin Console >> Actions >> Log Viewer >> Display Level: Info
Then search for 503 errors and entries around that. This will give you more information about the origin of your litespeed 503 error.
If this is also a cPanel server, you can find the error log on the Apache error_log at
/usr/local/apache/logs/error_log
Otherwise, if it is not a cPanel server, you can probably find it on the shell at
/usr/local/lsws/logs/error.log
You may find this kind of errors on the logs:
2017-04-06 11:00:41.060 [NOTICE] [XX.XX.XXX.XX:50758] request already in process for 278 seconds, fail with 503 2017-04-06 11:00:41.060 [NOTICE] [XX.XX.XXX.XX:50758] oops! 503 Service Unavailable
1) Increase Memory limits
Sometimes litespeed wil show a 503 error if your php scripts are trying to use more memory than the default available, often you will see this on the logs:
Fatal error: Allowed memory size of 288435456 bytes exhausted (tried to allocate 932351 bytes) in /home/johndoe/public_html/webroot/app/alter.php on line 104 2017-03-03 10:31:43.023 [STDERR]
Move to LSWS WebAdmin Console >> Server >> External App >> lsphp5:
- Memory Soft Limit (bytes)
- Memory Hard Limit (bytes)
As you see below:
Restart litespeed to apply changes:
service lsws restart
2) Increase LiteSpeed Timeout
The 503 error can often happen because low timeout values for LSWS. In order to fix it, move to:
WHM » Plugins » LiteSpeed Web Server Plugin » WebConsole Admin
Configuration » Server » click on Tunning tab.
Increase the ‘Connection Timeout (secs)’ variable, as you see below:
Restart lsws:
service lsws restart
3) Disable PHP Opcode Cache modules
If you are using PHP cache modules such as eaccelerator, xcache or opcache, first make sure you are not using two modules at the same time, and if that doesn’t solve your litespeed 503 error, then try to disable all those cache modules from your php configuration.
4) Disable 3rd Party Modules like ionCube, ZendGuardLoader, Suhosin
Same as happens on the Opcode caches, PHP modules like ioncube, suhosin or zendguard can cause 503 errors due to incompatibility issues
Disable this modules by commenting / removing the php.ini entries
Restart LSWS and try again:
service lsws restart
If you still need that PHP module, you can always upgrade to the latest version, or write a bug report to the developer
5) LFD killing your LiteSpeed and PHP processes
Started digging around and found that it was caused by CSF/LFD killing the php processes. To see if there are any php processes killed you can grep the logs, as you see below:
grep kill /var/log/lfd.log -i
This was the output in my case:
[[email protected]:~] grep kill /var/log/lfd.log -i Apr 5 18:00:03 host lfd[153633]: *User Processing* PID:119275 Kill:0 User:johndoe Time:5434 EXE:/usr/local/lsws/bin/lshttpd.5.1.14 CMD:lshttpd Apr 5 19:42:13 host lfd[865185]: *User Processing* PID:829747 Kill:0 User:user8 Time:5411 EXE:/usr/local/bin/lsphp CMD:lsphp Apr 5 19:43:13 host lfd[865609]: *User Processing* PID:829803 Kill:0 User:user2 Time:5461 EXE:/opt/cpanel/ea-php55/root/usr/bin/lsphp.cagefs CMD:lsphp
To fix this LiteSpeed 503 error, you can add the php process to the csf.pignore file, you can do it by running:
nano -w /etc/csf/csf.pignore
At the end of the line, paste this, for example:
exe:/opt/cpanel/ea-php55/root/usr/bin/lsphp.cagefs exe:/usr/local/lsws/bin/lshttpd.5.1.14 exe:/usr/local/bin/lsphp
A more drastic way to fix the issue, is to disable process tracking from CSF Firewall, it is not recommended but it will work too:
nano -w /etc/csf/csf.conf
CTRL + W and find this variable:
PT_LIMIT = "60"
and set it to
PT_LIMIT = "0"
Restart csf firewall and lfd service:
csf -r service lfd restart
Conclusion
As you see, there are many reasons on why this 503 error can happen while running LiteSpeed. The best advice is always check the logs, 99% of the times it will tell you the reason and you will know how to fix it from that point.
Recommended reading: