New in CWP Edge / LTSFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers. Available now in the Edge-Latest and LTS-Stable versions. Discuss in the forum

LSPHP / Cache ›
CWP Secure KernelKernel-level protectionEvery site in its own sandbox

Every PHP site, cron job and SSH session runs in its own profile that the kernel enforces. A hacked WordPress cannot read other accounts’ files, and crypto miners and unexpected processes are stopped. Discuss in the forum

Secure Kernel ›
CWP DataCenter PanelFree for CWPpro serversAll your servers on one screen

Manage all your CWP servers from one panel: live health, every hosting account, CWP and OS updates on many servers at once, backups, SSL, firewall and Telegram alerts. Discuss in the forum

DataCenter Panel ›
CWP Backup ServerFree for CWPpro serversBackups that ransomware cannot reach

Protected backups of all your CWP servers on a separate machine. Snapshots a hosting server cannot delete, and restore of files, databases, mail and whole accounts in the admin and user panel. Discuss in the forum

Backup Server ›
WordPress ManagerIncluded & freeWordPress managed from the panel

Install, secure, update, back up and clone WordPress sites without FTP. Updates are tested on a staging clone first and applied to the live site only when they pass, with a backup taken first. Discuss in the forum

WordPress Manager ›
CWP CageIsolationEvery account in its own cage

Per-account isolation built from Linux namespaces and cgroups. A break-in or a runaway script on one site cannot reach another account, the panel or the rest of the server; resource limits per hosting package. Discuss in the forum

CWP Cage ›
Script InstallerOne-click appsWordPress, Joomla, Moodle and more in one click

CWP’s own script installer in the user panel: pick an app, choose the domain and folder, and it is live in seconds with its database and admin login created automatically. Ready for LSPHP and LSAPI-Cache. Discuss in the forum

Script Installer ›
DNS ClusterFor every control panelOne DNS cluster for all your servers

Your servers keep creating domains as usual; the zones are collected into one authoritative PowerDNS cluster you control, with DNSSEC, roles and a full activity trail. Accepts CWP, cPanel, Plesk, DirectAdmin and BIND. Discuss in the forum

DNS Cluster ›
CWP BillingFree to useBilling and support system for hosting providers

Clients, services, invoices, payments, domains, server provisioning and support tickets in one place. All gateways, server modules and registrars are free, with free migration from WHMCS, ClientExec and Blesta. Discuss in the forum

CWP Billing ›
CWPproFrom $1.49 per monthEvery CWP feature unlocked

CWPpro is the professional version of Control Web Panel: all features, unlimited accounts, the latest CWP version and security fixes first. $1.49 per month or $11.99 per year. Discuss in the forum

Get CWPpro ›

Cloudflare returns 522 timeout errors when trying to connect to Apache PHP-FPM

Started by simonjwoolf, September 23, 2026, 07:16:10 AM

Previous topic - Next topic

simonjwoolf

I have a CWP Pro virtual server running AlmaLinux 8.10 and CWP 1.14

The server is never under any appreciable load - max 33% of processor capacity and 4GB of RAM from 16GB total. Checking the Apache Server Status via the CWP control panel, everything looks sane - 12 spawned servers, utilises 1.5GB RAM, 272 tasks.

All sites on the server use PHP-FPM, some stuck on legacy PHP7.4 but most running PHP8.3

Cloudflare returns a timeout error of 522 on some sites, seemingly at random but rather often. If I disable Cloudflare, I get the same timeouts but with a vanilla error message in the browser. So Cloudflare is not at fault here.

I have tried various tactics to prevent this:

a) Apache was reporting it had run out of RequestWorker processes, so I included the following snippet via conf/extra/httpd-mpm.conf (Apache runs with the MPM Evnt mod on my server).


<IfModule mpm_event_module>
    StartServers            25
    ServerLimit             32
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers    800
    MaxConnectionsPerChild   0
</IfModule>


b) When that didn't solve the problem, I also increased the number of max PHP-FPM processes in the default template and for individual sites. I increased from the default of MaxChildProcceses 4 to 25.

c) I enabled KeepAlive which I don't think is enabled by default, via self-authored snippet included in conf/extra/httpd-keepalive.conf

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5


None of the above has resolved the problem. I am at a loss. Furthermore, some of the sites show extremely poor performance. Yet the server has loads of spare capacity.

Anyone got any insight here?

I have checked if disabling the firewall made any difference (in case it was blocking Cloudflare IP addresses). It did not and it is not.

cyberspace

1. Check how many processes are running under the user account of the problematic website when the error occurs.

2. Make sure the number of processes is not close to the Process Limit specified for the account in the CWP admin panel (check the account properties).

3. Check the package limits assigned to the problematic account. Pay particular attention to nproc, apache_nproc, and nofile.

4. Is mod_security enabled ?

5. Do you use a VPS or a dedicated server? If it's a VPS, what type of virtualization is used?

simonjwoolf

Quote from: cyberspace on September 23, 2026, 11:28:41 PM
1. Check how many processes are running under the user account of the problematic website when the error occurs.

2. Make sure the number of processes is not close to the Process Limit specified for the account in the CWP admin panel (check the account properties).

3. Check the package limits assigned to the problematic account. Pay particular attention to nproc, apache_nproc, and nofile.

Thanks - this is a great tip that had not occurred to me. I have increased all those limits now, will monitor and see if it improves things.

Quote
4. Is mod_security enabled ?

Yes

Quote
5. Do you use a VPS or a dedicated server? If it's a VPS, what type of virtualization is used?

It's a VPS, running on Hetzner Cloud (KVM)

Freespirits_GR_Host

The fact that you still get the timeout with Cloudflare disabled is useful because it largely removes Cloudflare from the equation. I also wouldn't increase MaxRequestWorkers or PHP-FPM children any further until you identify which layer is actually saturating.

When the timeout happens, I'd capture the state at that exact moment rather than looking only at overall CPU/RAM. Check the affected account's PHP-FPM processes, its CWP process/package limits (nproc, apache_nproc, nofile), Apache scoreboard, and the corresponding PHP-FPM slow/error log. Also compare pm.max_children against the number of active/queued requests for that pool.

One particularly useful test would be to run several simultaneous requests directly against the origin while watching the affected PHP-FPM pool. If requests begin queueing while the machine still has free CPU/RAM, you've found a concurrency/limit bottleneck rather than a server-capacity problem.

I'd also temporarily correlate the timeout timestamps with ModSecurity audit entries. That should help distinguish PHP-FPM saturation, account limits, Apache worker exhaustion and request filtering instead of changing several limits at once.

I develop CWP7 Turbo Manager, specifically around diagnosing and tuning this sort of CWP web-stack performance problem. Full disclosure: I'm the developer. It may be relevant here, but I'd first capture the PHP-FPM/account state during one of the 522 events—the numbers from that moment should tell us which direction to go.
CWP is already an excellent hosting control panel. We simply make a great tool even better! ??

At FreeSpirits Web Services, we create complementary modules that enhance CWP's security, performance and server management.

Security Audit | Resource Shield | Tweak Manager | Turbo Manager

Need fast, secure, affordable web hosting and responsive technical support?
FreeSpirits Web Services - Your hosting partner, your peace of mind!

simonjwoolf

Thank you, this is very useful.

Actually when I checked the PHP-FPM slow logs (which I had not thought to do previously) I quickly discovered a site with a simple hack. It was hanging on the homepage due to a hack on the index.php executing various encrypted commands with curl.

Cleaning up the hack immediately improved performance to what I would expect!