Updated: 22 October 2026 · Applies to: Engintron 2.13 on cPanel and WHM (AlmaLinux, Rocky Linux, CloudLinux); log lines reproduced with Nginx 1.30.5 in a lab

A "502 Bad Gateway" page from Engintron means Nginx, which answers visitors on ports 80 and 443, could not get a valid answer from Apache, which Engintron moves to ports 8080 and 8443. Read the last lines of /var/log/nginx/error.log: they say why. The two usual causes are that Apache is not running (restart it) or that Nginx sends the request to the wrong address because the domain does not resolve to your server, for example behind Cloudflare (set your server IP as $PROXY_DOMAIN_OR_IP in Engintron's custom_rules).

500 or 502: which error do you have?

  • 500 Internal Server Error comes from the website itself: Apache and PHP answered, but the script or a .htaccess rule failed. Nginx just passes the 500 on. Fix it in the site (see How do I fix a 500 Internal Server Error?).
  • 502 Bad Gateway comes from Nginx: it got no usable answer from Apache at all (refused, dropped or unreachable).
  • 504 Gateway Timeout also comes from Nginx: Apache accepted the request but did not answer in time.

In our lab (Nginx in front of a stand-in backend on port 8080, the same layout Engintron uses), a backend that returned an error gave HTTP 500 to the visitor, while a stopped backend gave HTTP 502.

Step 1: read the Nginx error log

In WHM, open Engintron for cPanel/WHM (under Plugins, or search for Engintron) and use Show last 100 error log entries in the Nginx section. Over SSH as root:

tail -n 30 /var/log/nginx/error.log

Find the line for the failing request and match it below.

Step 2: match the log line to the cause

connect() failed (111: Connection refused)

Output (from our lab):

connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: example.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "example.com"

Nothing listens on the Apache port. Check and restart Apache with cPanel's own script:

/usr/local/cpanel/scripts/restartsrv_httpd --check
/usr/local/cpanel/scripts/restartsrv_httpd --restart

If Apache does not start, its error log says why (according to cPanel, /etc/apache2/logs/error_log on EasyApache 4). Also check that Apache's port in WHM, Tweak Settings, is still 0.0.0.0:8080: Engintron sets this, and a different value means Apache and Nginx no longer meet.

could not be resolved

Output (from our lab):

example.com could not be resolved (110: Operation timed out), client: 127.0.0.1, server: example.com, request: "GET /ok HTTP/1.1", host: "example.com"

By default Engintron proxies each request to the visitor's domain name, which Nginx looks up in public DNS (the resolver in Engintron's nginx.conf is 1.1.1.1 and 1.0.0.1). If outgoing DNS is blocked by the firewall, or the domain points somewhere else, the lookup fails or returns the wrong server. Fix it with Step 3.

Requests reach the wrong server (Cloudflare, new domains)

When a domain is behind Cloudflare's proxy, or its DNS does not point to your server yet, Nginx resolves it to an address that is not your Apache. According to Engintron, sites on Cloudflare then show Cloudflare 10xx errors or fail to load. Fix it with Step 3.

upstream prematurely closed connection

Output (from our lab):

upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /drop HTTP/1.1", upstream: "http://127.0.0.1:8080/drop", host: "example.com"

Apache accepted the request but the connection ended before an answer: usually a PHP process that crashed or was killed (memory limit, a resource limit, a faulty extension). Check Apache's error log and the site's PHP error log for the same time.

110: Connection timed out (and 504 errors)

According to Engintron, this points to a slow backend (Apache, PHP or the database). In Engintron 2.13 Nginx waits 300 seconds (proxy_read_timeout in proxy_params_common). Raising it is a quick fix; making the site faster is the real one.

Step 3: point Nginx at your server IP (custom_rules)

  1. In WHM, open Engintron for cPanel/WHM and click Edit your custom_rules for Nginx.
  2. If all sites on the main shared IP should go straight to Apache, remove the # in front of the set $PROXY_DOMAIN_OR_IP line and put in your server's shared IP (the private IP if the server is behind NAT):
    set $PROXY_DOMAIN_OR_IP "203.0.113.10";
  3. For a domain on its own dedicated IP, add a block per domain:
    if ($host ~ "example.com") {
        set $PROXY_DOMAIN_OR_IP "203.0.113.20";
    }
  4. Leave Reload or restart related services ticked and click the Update /etc/nginx/custom_rules button below the editor.
  5. Load the site again. If it still fails, use Restart Apache & Nginx in Engintron, or over SSH:
    engintron res

In our lab, the same request that failed with "could not be resolved" returned HTTP 200 as soon as the proxy address was set to the IP.

Other checks

  • Firewall: according to Engintron, a firewall such as CSF must allow ports 8080 and 8443, which Apache uses behind Nginx. See CSF Firewall Commands and Settings on cPanel.
  • Is it Nginx or Apache? engintron disable moves Apache back to ports 80 and 443 and Nginx to 8080 and 8443. If the site works then, the problem is between the two; engintron enable switches back.
  • Another Nginx plugin: according to Engintron, remove any other Nginx plugin for cPanel before installing Engintron.
  • Ubuntu: Engintron 2.13 supports the EL family only (AlmaLinux, Rocky Linux, CloudLinux); its developer plans Ubuntu for version 3.

Engintron or cPanel NGINX?

cPanel now ships its own NGINX with reverse proxy (package ea-nginx, in WHM under Software, NGINX Manager), supported by cPanel directly. The same log lines apply there; restart it with /usr/local/cpanel/scripts/restartsrv_nginx. The comparison is in Nginx on cPanel: Engintron or cPanel NGINX Reverse Proxy, and the Engintron setup in Engintron installation and configuration.

Official documentation: Engintron documentation, Engintron on GitHub, cPanel restartsrv script.

Related services

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

cPanel server management

hardening, migrations and 24/7 monitoring, with no long-term contract.

cPanel, Plesk and LiteSpeed licences

for VPS and dedicated servers, with installation help on demand.

Was this answer helpful?

Still stuck? Open a ticket