Fix: Service Unavailable Error on CloudLinux Servers

Fix: Service Unavailable Error on CloudLinux Servers

The "Service Unavailable" error is one of the most common issues on shared hosting servers running CloudLinux with CageFS and mod_lsapi. This error indicates that the server could not process the visitor's request, usually because the PHP backend (lsphp) failed to connect.

In this article, you will learn how to identify the root cause of the problem and apply the correct solution based on the scenario.

Common causes

  1. Outdated or corrupted CageFS: After a server restart, account restoration, or CloudLinux update, the CageFS virtual environment may be left in an inconsistent state.
  2. LVE limits reached: CloudLinux assigns CPU, memory, process (EP), and connection limits to each account. If an account reaches any of these limits, the server rejects requests with "Service Unavailable".
  3. mod_lsapi cannot connect to lsphp: The Apache module that connects to the PHP backend fails to establish communication, generating the error connect to lsphp failed: 110.
  4. Orphaned lsphp processes: PHP processes that got stuck and are consuming the user's available slots.

Diagnosis

Check Apache error log

The first step is to identify the exact error in the Apache log. Search for recent entries from the affected user:

grep -i cpanel_user /usr/local/apache/logs/error_log | tail -20

The typical error related to mod_lsapi and CageFS looks like this:

[lsapi:error] [pid 23113:tid 47912125892352] [client 187.188.127.42:46658] mod_lsapi: [host example.com] [req GET / HTTP/1.1] Connect to backend failed: connect to lsphp failed: 110

Check LVE limits

Check if the user has reached any resource limits recently:

lveinfo --user cpanel_user --period=1h

If you see non-zero fault values (fEP, fNPROC, fPMEM, fVMEM), the account is hitting its limits.

Check CageFS status

Verify that CageFS is active and working correctly for the user:

cagefsctl --check-cagefs

Check for orphaned lsphp processes

Verify if there are stuck PHP processes for the user:

ps aux | grep lsphp | grep cpanel_user

Solution 1: Remount CageFS for a single user

If the error affects a single site or account, remount the CageFS virtual environment for that specific user:

cagefsctl -m cpanel_user

Verify that the site loads correctly after running the command.

Solution 2: Repair CageFS for the entire server

If multiple sites show the error simultaneously (for example, after a restart or update), update and remount CageFS for all users:

cagefsctl --force-update
cagefsctl -M

Note: The cagefsctl -M command (uppercase) remounts CageFS for all users on the server. On servers with many accounts, this process may take several minutes.

Solution 3: Kill orphaned lsphp processes

If you identified stuck PHP processes, kill them to free the user's slots:

killall -u cpanel_user lsphp

If you want to kill lsphp processes for all users (use with caution):

killall lsphp

Solution 4: Adjust LVE limits

If the diagnosis revealed that the account is reaching its resource limits, you can adjust them temporarily from the command line or permanently from WHM.

Command line adjustment

To increase the Entry Processes (EP) limit to 30 for a user:

lvectl set cpanel_user --ep=30

To increase the NPROC (maximum number of processes) limit to 50:

lvectl set cpanel_user --nproc=50

Apply the changes without restarting:

lvectl apply all

Adjustment from WHM

  1. Log in to WHM.
  2. Navigate to CloudLinux LVE Manager.
  3. Search for the affected user in the Current Usage tab.
  4. Click the edit icon and adjust the EP, NPROC, PMEM, or CPU values as needed.

Solution 5: Restart mod_lsapi

If the problem persists after the previous solutions, restart the mod_lsapi service and Apache:

/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/restartsrv_httpd

If you use LiteSpeed instead of Apache:

/scripts/restartsrv_litespeed

Post-solution verification

After applying any of the solutions above, verify that the problem has been resolved:
  1. Open the affected website in a browser and confirm it loads correctly.
  2. Check that no new lsapi errors appear in the log:
tail -f /usr/local/apache/logs/error_log | grep -i lsapi

  1. Monitor the user's LVE limits over the following hours:
lveinfo --user cpanel_user --period=1h

Quick command reference

  1. cagefsctl -m user — Remount CageFS for a single user.
  2. cagefsctl --force-update — Force CageFS update.
  3. cagefsctl -M — Remount CageFS for all users.
  4. cagefsctl --check-cagefs — Check CageFS status.
  5. lveinfo --user user --period=1h — Check LVE faults.
  6. lvectl set user --ep=30 — Adjust Entry Processes limit.
  7. lvectl apply all — Apply LVE changes.
  8. killall -u user lsphp — Kill lsphp processes for a user.
  9. /scripts/restartsrv_httpd — Restart Apache.

Recommendations

  1. Always diagnose first before applying solutions. Check the error_log and LVE limits to identify the root cause.
  2. If the error recurs frequently for the same user, the account likely needs a hosting plan with more resources or application optimization (caching, plugins, database queries).
  3. After CloudLinux or kernel updates, run cagefsctl --force-update followed by cagefsctl -M as a preventive measure.
  4. Set up alerts in CloudLinux LVE Manager to receive notifications when a user frequently reaches their resource limits.
  5. Consider implementing LVE Warden (available on CloudLinux 8+) to automate limit management based on usage patterns.

    • Related Articles

    • Fix MySQL Stored Procedures Import Error in cPanel

      When working with MySQL databases that include stored procedures, it's common to encounter errors during import in shared hosting environments with cPanel. These errors are usually related to the DEFINER parameter, which specifies the owner of the ...
    • 'Never Finished' error in JetBackup 5

      The "Never Finished" error in JetBackup happens when a backup job doesn’t complete properly, leaving the process stuck in a "never finished" state. This issue can pop up for a bunch of reasons, like JetBackup services acting up, cache problems, or ...
    • JetBackup 5: How to fix the Integrity Check error using CLI/SSH

      When JetBackup performs its automated integrity verification processes, they may sometimes complete partially due to network interruptions, timeouts, or communication issues with the remote storage destination. If you receive notifications indicating ...
    • How to change File Permissions and Ownership via Command Line

      Files and folders with incorrect permissions or ownership can be vulnerable to unauthorized access, potentially compromising the integrity of your data and the security of your website. Additionally, these issues can cause read, write, or execution ...
    • How to Install cPanel on Your Server or VPS: Updated Guide by Distribution

      cPanel & WHM is the most widely used control panel in the web hosting industry. If you have a dedicated server or VPS with Webzi (or any other provider), this guide shows you how to install cPanel from scratch on the currently supported operating ...