Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:php:503-errors [2018/10/01 20:05]
Jackson Zhang [The lsphp process is killed unexpectedly by CSF/LFD]
litespeed_wiki:php:503-errors [2020/02/11 14:26] (current)
Jackson Zhang [Magento 503 error]
Line 199: Line 199:
 ==== CloudLinux Limits Reached =====  ==== CloudLinux Limits Reached ===== 
  
-For CloudLinux users, if a site is limited by either the amount of memory or the number of processes, then the user will receive 503 errors because the server cannot execute the script. Increasing the limits on memory and number of processes for that CageFS user may fix the problem.+For CloudLinux users, if a site is limited by either the amount of memory or the number of processes, then the user will receive 503 errors because the server cannot execute the script. Increasing the limits on memory and number of processes for that CageFS user may fix the problem. ​To understand why LVE may cause such error, please refer to [[https://​docs.cloudlinux.com/​index.html?​lve.html|CloudLinux LVE documentation]]. 
 + 
 +  If the site is limited by CPU or IO, then the site will start responding slower. 
 +  If the site is limited by memory or number of processes limits, then the user will recieve 500 or 503 errors that server cannot execute the script. 
  
 ==== PHP memory_limit reached ==== ==== PHP memory_limit reached ====
Line 290: Line 294:
 These settings will need to be adjusted on a per case basis as each scenario will be different. They should be increased slightly higher than the current values until the issue stops occurring. For the changes to take effect, both csf and lfd will need to be restarted. This can either be done via the WHM Plugin or through a shell terminal with the following command: ''​csf -r; service lfd restart''​ These settings will need to be adjusted on a per case basis as each scenario will be different. They should be increased slightly higher than the current values until the issue stops occurring. For the changes to take effect, both csf and lfd will need to be restarted. This can either be done via the WHM Plugin or through a shell terminal with the following command: ''​csf -r; service lfd restart''​
  
-==== Misconfiguration of lsphp external application ​==== +==== Misconfiguration of "lsphp" External Application ​==== 
-During ​the LSWS installation,​ external ​application ​will be automatically set to the best value of the general ​situation. However, sometimes the user intentionally removes ​something which causes misconfiguration and may cause 503 error.+During ​LiteSpeed Web Server ​installation,​ external ​applications ​will be automatically set to the best value for general ​use. However, sometimes the user intentionally removes ​some of these settings. This causes ​misconfiguration and possibly also a 503 error.
  
-For PHP external app, LSWS will normally add the following to it as default.+For PHP external app, LSWS will normally add the following to it by default:
     <​memSoftLimit>​2047M</​memSoftLimit>​     <​memSoftLimit>​2047M</​memSoftLimit>​
     <​memHardLimit>​2047M</​memHardLimit>​     <​memHardLimit>​2047M</​memHardLimit>​
Line 299: Line 303:
     <​procHardLimit>​1500</​procHardLimit>​     <​procHardLimit>​1500</​procHardLimit>​
  
-but some user intentionally ​removed ​the above without any clear purpose. When the resource limit was not set, LSWS will use CGI resource limit as default ​while the CGI resource limit is too low to meet the requirement. If the PHP is configured to have 500 max connections,​ it requires to have 500 children processes, the process limit needs to be setup to minimum 1000. The above misconfiguration caused 503 error on LSWS+Imagine a user intentionally ​removes ​the above without any clear purpose. When the resource limit is not set, LSWS will use the CGI resource limit by default, but the CGI resource limit is too low to meet the requirements
  
-We recommend not to remove anything if you are unsure ​and cause an uncertain problem, ​such as 503 error as this case+If the user has configured PHP to have 500 max connections:​ 
 +     <​maxConns>​500</​maxConns>​ 
 + 
 +Then it must have 500 child processes:  
 +     <​env>​PHP_LSAPI_CHILDREN=500</​env>​ 
 + 
 +The "500 max connections"​ setting requires "​process limit" to be set at a minimum of "​1000."​ But since the user incorrectly removed the PHP process limit settings, the above misconfiguration caused a 503 PHP error when running LSWS.  
 + 
 +We recommend ​that you do not to remove anything if you are unsure, as it can cause an uncertain problem, ​including a 503 error. ​
 ====  Apache and LiteSpeed using unmatched PHPs could cause problems for control panel users ====  ====  Apache and LiteSpeed using unmatched PHPs could cause problems for control panel users ==== 
 If you use a control panel such as cPanel or Plesk, make sure both PHPs for Apache and LiteSpeed are matching each other. To test this, you can create a phpinfo page under your domain and switch between both web servers to check. If these PHPs do not match you could end up with 503 errors. If you use a control panel such as cPanel or Plesk, make sure both PHPs for Apache and LiteSpeed are matching each other. To test this, you can create a phpinfo page under your domain and switch between both web servers to check. If these PHPs do not match you could end up with 503 errors.
Line 332: Line 344:
   - Comment out the ''​extension_dir''​ line to let PHP pick a default.   - Comment out the ''​extension_dir''​ line to let PHP pick a default.
  
 +==== ''​Too many open files''​ error may cause 503 error ====
 +If you found there are a lot of ''​Too many open files!''​ errors, which cause 503 errors. ​
 +
 +<​code>​
 +  grep "Too many open files" error_log
 +
 +2019-08-01 21:​58:​03.511076 [INFO] [319934] [157.33.150.151:​49873-1#​APVH_pcrm.lidopiegade.lv:​lsapi] connection to [uds://​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock] on request #0, confirmed, 0, associated process: 0, running: 0, error: Too many open files!
 +2019-08-01 21:​58:​03.511078 [INFO] [319934] [uds://​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock] Connection error: Too many open files, adjust maximum connections to 4!
 +2019-08-01 21:​58:​03.511085 [NOTICE] [319934] [APVH_lidopiegade_Sulsphp56:​]:​ Failed to open pid file [/​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock.pid]:​ Too many open files
 +2019-08-01 21:​58:​03.511087 [ERROR] [319934] [APVH_lidopiegade_Sulsphp56:​]:​ Failed to lock pid file for [/​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock]:​ Too many open files
 +2019-08-01 21:​58:​03.809177 [ERROR] [319934] [HTAccess] Failed to open [/​home/​zazzybab/​public_html/​girls/​shannon-stewart/​.htaccess]:​ Too many open files
 +2019-08-01 21:​58:​03.810914 [ERROR] [319934] [46.51.216.186:​63901] /​home/​zazzybab/​public_html/​girls/​shannon-stewart/​shannon-stewart-playboy-33645.jpg:​ open() failed, 24:Too many open files
 +2019-08-01 21:​58:​05.072915 [NOTICE] [319934] [APVH_lidopiegade_Sulsphp56:​]:​ Failed to open pid file [/​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock.pid]:​ Too many open files
 +2019-08-01 21:​58:​05.072918 [ERROR] [319934] [APVH_lidopiegade_Sulsphp56:​]:​ Failed to lock pid file for [/​tmp/​lshttpd/​APVH_lidopiegade_Suea-php56.sock]:​ Too many open files
 +2019-08-01 21:​58:​05.072932 [NOTICE] [319934] [APVH_birkenfelds_Sulsphp56:​]:​ Failed to open pid file [/​tmp/​lshttpd/​APVH_birkenfelds_Suea-php56.sock.pid]:​ Too many open files
 +2019-08-01 21:​58:​05.072934 [ERROR] [319934] [APVH_birkenfelds_Sulsphp56:​]:​ Failed to lock pid file for [/​tmp/​lshttpd/​APVH_birkenfelds_Suea-php56.sock]:​ Too many open files
 +2019-08-01 21:​58:​05.072949 [NOTICE] [319934] [APVH_vairaksaules_Sulsphp56:​]:​ Failed to open pid file [/​tmp/​lshttpd/​APVH_vairaksaules_Suea-php56.sock.pid]:​ Too many open files
 +2019-08-01 21:​58:​05.072951 [ERROR] [319934] [APVH_vairaksaules_Sulsphp56:​]:​ Failed to lock pid file for [/​tmp/​lshttpd/​APVH_vairaksaules_Suea-php56.sock]:​ Too many open files
 +
 +</​code>​
 +
 +You may want to check the current ulimit:
 +  ulimit -n
 +  32768
 +you may consider to increase to a much higher value like:
 +  ulimit -n 3276800
 +  ​
 +Check [[litespeed_wiki:​config:​increasing-os-file-descriptor-limit|this wiki]] for details.
 ==== Magento 503 error ==== ==== Magento 503 error ====
 After (re)installation of LiteMage Cache extension in Magento Connect manager or enable other modules in Magento 2, Magento site may be placed in maintenancence mode and couldn'​t be accessed and may give 503 errors. ​ Please refer [[litespeed_wiki:​cache:​litemage:​troubleshooting:​connect-cache-session-cleaning-error|this]] for details. After (re)installation of LiteMage Cache extension in Magento Connect manager or enable other modules in Magento 2, Magento site may be placed in maintenancence mode and couldn'​t be accessed and may give 503 errors. ​ Please refer [[litespeed_wiki:​cache:​litemage:​troubleshooting:​connect-cache-session-cleaning-error|this]] for details.
  
 +==== Some buggy application plugin may cause 503 error ====
 +Some buggy application plugin, such as WordPress sportspress plugin used to cause 503 errors. Uninstall all or most of WordPress or other applications'​ plugins, then installing them back one by one may be a good approach to locate the problematic plugin. ​
 +==== CloudLinux Imunify360 error ====
 +
 +Check ''​stderr.log''​. It shows:
 +<​code>​
 +  *** Error in '​lsphp:/​home/​ukrainia/​public_html/​index.php':​ malloc(): memory corruption (fast): 0x00007fa380d45e40 ***
 +  ======= Backtrace: =========
 +  /​lib64/​libc.so.6(+0x7f574)[0x7fa37c07f574]
 +  /​lib64/​libc.so.6(+0x82c90)[0x7fa37c082c90]
 +  /​lib64/​libc.so.6(__libc_malloc+0x4c)[0x7fa37c0857dc]
 +  /​opt/​cpanel/​ea-php54/​root/​usr/​lib64/​php/​modules/​i360.so(+0xb80b)[0x7fa375fbe80b]
 +  /​opt/​cpanel/​ea-php54/​root/​usr/​lib64/​php/​modules/​i360.so(map_increment_int_+0xa2)[0x7fa375fbeaa2]
 +</​code>​
 +
 +If you try the following:
 +
 +**/​opt/​cpanel/​ea-php54/​root/​usr/​lib64/​php/​modules>​** ''​mkdir backup''​
 +
 +**/​opt/​cpanel/​ea-php54/​root/​usr/​lib64/​php/​modules>​** ''​mv i360.so backup/''​
 +
 +**/​opt/​cpanel/​ea-php54/​root/​usr/​lib64/​php/​modules>​** ''​ls -l i360.so backup/''​
 +
 +You will get this result:
 +
 +  ls: cannot access i360.so: No such file or directory
 +  backup/:  ​
 +  total 88
 +  -rwxr-xr-x 1 root root 86568 Nov 15 12:37 i360.so
 +
 +The issue is fixed by disabling CloudLinux'​s ''​i360.so''​. This is a CloudLinux bug. Please be aware that it may have been fixed by the CloudLinux team by the time you read this wiki, but it was a cause of 503 errors at one time.
 +
 +==== Plesk 503 error ====
 +Some versions of Plesk PHP, such as php71 and php56, have a buggy APCu module that may cause a 503 error on LSWS. Generally, only one object cache or value cache should be enabled. Enabling two or more may cause conflicts between modules. ​ Disabling the APCu module should fix the problem. ​
 +
 +Navigate to **Plesk Admin > Tools and configuration > PHP configuration > 7.1.x FastCGI application**. Unselect ''​apcu''​ and press the **TO ACCEPT** button.
 +{{ :​litespeed_wiki:​php:​plesk-503-disable-apcu.png?​800 |}}
 +
 +==== CPanel WebDisk 503 Errors ====
 +You might see some errors like the following:
 +  2019-03-12 12:​14:​00.324041 [INFO] [51.68.79.11:​54920:​proxy] connection to [127.0.0.1:​2077] on request #1, confirmed, 0, associated process: 0, running: 0, error: Connection refused!
 +  2019-03-12 12:​14:​00.324165 [INFO] [51.68.79.11:​54920:​proxy] connection to [127.0.0.1:​2077] on request #1, confirmed, 0, associated process: 0, running: 0, error: Connection refused!
 +  2019-03-12 12:​14:​00.324194 [NOTICE] [51.68.79.11:​54920:​proxy] Max retries has been reached, 503!
 +  2019-03-12 12:​14:​00.324206 [INFO] [http://​127.0.0.1:​2077] request force stop: too many 503 errors
 +
 +Check ''/​etc/​apache2/​conf/​httpd.conf'':​
 +   ​ProxyPass "/​___proxy_subdomain_webdisk"​ "​http://​127.0.0.1:​2077"​ max=1 retry=0
 +
 +The errors are coming from cPanel WebDisk service. If this service generates too many 503 errors, you might consider disabling it. To disable cPanel WebDisk, you can log into WHM and disable **cPanel DAV Daemon** in the **Service Manager**.
 +
 +==== chroot is Enabled in LSWS =====
 +It is not recommended to use ''​chroot''​ at all. If enabled, it may lead to a 503 error. To fix the problem, in the LiteSpeed Web Server WebAdmin Console, navigate to **Server > General** and set **Enable chroot** to ''​No''​.
  
 ===== Advanced Troubleshooting Guide ===== ===== Advanced Troubleshooting Guide =====
Line 434: Line 526:
  
 This backtrace shows us that the program crashed soon after accessing the opcode cache. This suggests that the issue is with the opcode cache. The user can then try upgrading the opcode cache or changing their PHP version. If neither of those work, the user should try to disable the opcode cache. This backtrace shows us that the program crashed soon after accessing the opcode cache. This suggests that the issue is with the opcode cache. The user can then try upgrading the opcode cache or changing their PHP version. If neither of those work, the user should try to disable the opcode cache.
 +
 +===== The "Auto Fix 503 Error" Feature =====
 +In LiteSpeed Web Server'​s WebAdmin Console, there is a feature to **Auto Fix 503 Error**. It specifies whether to try to fix the "503 Service Unavailable"​ error by restarting the server gracefully. A "​503"​ error is usually caused by malfunctioning external applications and a web server restart can often fix the error temporarily. If **Auto Fix 503 Error** is set to ''​Yes'',​ the server will restart automatically whenever there are more than 30 "​503"​ errors within a 30 seconds span. This feature is enabled by default, but you can disable it by navigating to **LSWS Admin -> Server -> General** and setting **Auto Fix 503 Error** to ''​No''​. ​
 +
 +{{ :​litespeed_wiki:​php:​auto-fix-503-error.png?​800 |}}
 +
 +**Auto Fix 503 Error** is not a permanent fix. You should not rely on this feature to fix recurring 503 errors. Going through the above steps to find a permanent fix is always recommended. ​
  
 ===== Real World Examples ===== ===== Real World Examples =====
  • Admin
  • Last modified: 2018/10/01 20:05
  • by Jackson Zhang