502 Bad Gateway

April 17, 2025
0
(0)

A 502 Bad Gateway error right after a reboot usually means a service your web server relies on didn’t start properly — such as Nginx (if you use Engintron), Apache, PHP-FPM, or MySQL.

Let’s troubleshoot this step by step:


Step 1: Check Apache & PHP-FPM status

Run:

bash
systemctl status httpd
systemctl status php-fpm

If any of them is inactive or failed, restart it:

bash
systemctl restart httpd
systemctl restart php-fpm

If you’re using Engintron, it adds Nginx as a reverse proxy:

bash
systemctl restart nginx

Step 2: Restart cPanel services

Sometimes restarting all WHM/cPanel-related services helps:

bash
/scripts/restartsrv_httpd
/scripts/restartsrv_nginx
/scripts/restartsrv_php-fpm

You can also try:

bash
/scripts/restartsrv_cpsrvd

Step 3: Check what is listening on port 80 and 443

bash
netstat -tulnp | grep ':80\|:443'

Make sure httpd (Apache) or nginx (if using Engintron) is bound to those ports.


Step 4: Look for actual error logs

Check Apache error logs:

bash
tail -n 100 /etc/apache2/logs/error_log # or:
/usr/local/apache/logs/error_log

If using Nginx (Engintron):

bash
tail -n 100 /etc/nginx/logs/error.log

Step 5: Check MySQL is running

If your websites use databases (e.g. WordPress), check MySQL:

bash
systemctl status mysql

If it’s not running:

bash
systemctl restart mysql

Step 6: Check Engintron Panel (if installed)

In WHM:

rust
Home » Plugins » Engintron for cPanel/WHM

From there, use the “Restart Nginx + PHP-FPM + MySQL” button.


Step 7: Check Firewall/IP blocks

Run:

bash
csf -g your.server.ip

To check if your own IP is blocked (if using CSF/LFD).


Let me know what you find from the service status or logs, and I’ll help pinpoint the exact cause. If you drop the output here, I can review it immediately.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

Your email address will not be published. Required fields are marked *