502 Bad Gateway Error on Raspberry Pi After Reboot – HestiaCP & WordPress

Hey everyone,

I’m having a recurring issue with my Raspberry Pi web server, and I’d appreciate any help troubleshooting.

Setup Details:

  • Hardware: Raspberry Pi
  • Control Panel: HestiaCP
  • Web Server: Nginx
  • PHP Version: 8.2 (PHP-FPM)
  • CMS: WordPress
  • Local Domain: pi.local

Issue:

After installing HestiaCP and setting up WordPress, my site (pi.local) works fine until I reboot. Once I restart the Raspberry Pi, I get a “502 Bad Gateway” error when trying to access the site.

The only way I’ve been able to fix it is by deleting the pi.local domain in HestiaCP, recreating it, and reinstalling WordPress. However, this only works until the next reboot.

What I’ve Checked:

:white_check_mark: PHP-FPM service (php8.2-fpm.service) is running after reboot.
:white_check_mark: Assigned a static IP to the Raspberry Pi and mapped pi.local to it in /etc/hosts to ensure consistent name resolution.
:white_check_mark: Checked Nginx and PHP-FPM logs for errors.
:x: Discovered that Apache2 is not restarting properly after a reboot.

Looking for Help With:

  • Why does this “502 Bad Gateway” error keep happening after reboot?
  • How can I ensure Apache2 starts automatically on reboot?
  • Any better ways to keep the setup stable without needing to delete/recreate the domain each time?

Bonus Question:

Which server control panel do you recommend for local WordPress installations? I’m using HestiaCP, but I’d love to hear if anyone has better alternatives for Raspberry Pi setups.

Thanks in advance!

Have you checked the Nginx and PHP-FPM logs? They might give you a clue about what’s happening after the reboot.

Ishani said:
Have you checked the Nginx and PHP-FPM logs? They might give you a clue about what’s happening after the reboot.

Thanks for the suggestion! It turns out Apache2 wasn’t restarting properly after a reboot. Fixed it now!

It sounds like Nginx might not be saving the domain settings correctly or could be having trouble routing to the correct PHP version.

It seems like there might be a proxy issue where something isn’t starting up correctly after a reboot. Have you reached out to HestiaCP support?

PixelPaladin said:
It seems like there might be a proxy issue where something isn’t starting up correctly after a reboot. Have you reached out to HestiaCP support?

Good thought! It turned out that Apache2 wasn’t starting properly after a reboot (sudo service --status-all helped me figure it out).

Did you check if the Nginx service starts correctly after reboot? Also, tweaking PHP-FPM settings or ensuring that Nginx waits for PHP-FPM might help stabilize things.