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
- Outdated or corrupted CageFS: After a server restart, account restoration, or CloudLinux update, the CageFS virtual environment may be left in an inconsistent state.
- 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".
- 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. - 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
- Log in to WHM.
- Navigate to CloudLinux LVE Manager.
- Search for the affected user in the Current Usage tab.
- 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:
- Open the affected website in a browser and confirm it loads correctly.
- Check that no new lsapi errors appear in the log:
tail -f /usr/local/apache/logs/error_log | grep -i lsapi
- Monitor the user's LVE limits over the following hours:
lveinfo --user cpanel_user --period=1h
Quick command reference
cagefsctl -m user — Remount CageFS for a single user.cagefsctl --force-update — Force CageFS update.cagefsctl -M — Remount CageFS for all users.cagefsctl --check-cagefs — Check CageFS status.lveinfo --user user --period=1h — Check LVE faults.lvectl set user --ep=30 — Adjust Entry Processes limit.lvectl apply all — Apply LVE changes.killall -u user lsphp — Kill lsphp processes for a user./scripts/restartsrv_httpd — Restart Apache.
Recommendations
- Always diagnose first before applying solutions. Check the error_log and LVE limits to identify the root cause.
- 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).
- After CloudLinux or kernel updates, run
cagefsctl --force-update followed by cagefsctl -M as a preventive measure. - Set up alerts in CloudLinux LVE Manager to receive notifications when a user frequently reaches their resource limits.
- Consider implementing LVE Warden (available on CloudLinux 8+) to automate limit management based on usage patterns.