惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
宝玉的分享
宝玉的分享
量子位
博客园 - Franky
The Cloudflare Blog
博客园 - 【当耐特】
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
V
V2EX
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
博客园 - 聂微东
F
Fortinet All Blogs
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
人人都是产品经理
人人都是产品经理

DigitalOcean Community Questions

Droplet stuck: "Power on" and "Snapshot" both in Executing state for hours - what are my options? | DigitalOcean Referral Link Not Working anymore | DigitalOcean Recent console change has destroyed capacity to connect to legacy FreeBSD installs | DigitalOcean issue after moving app from aws to digitalocean | DigitalOcean issue after moving app from aws to digitalocean | DigitalOcean Container registry auomated garbage cillection sign in | DigitalOcean Billings And Free Tier Offer | DigitalOcean Switch hostinger to digitalocean? | DigitalOcean Unable to connect to Droplet via Console – “Failed to get droplet info” error | DigitalOcean billing problem | DigitalOcean How do I migrate an old Xen DomU VM, backed by a DRBD volume, to Digital Ocean? | DigitalOcean Account Locked After Payment Method Attempt (Hatch Program) - No Clear Reason | DigitalOcean Ghost Blog Marketplace Droplet is Ubuntu 22.04, not Ubuntu 24.04 | DigitalOcean How to setup browser with openclaw | DigitalOcean unable to load CA private key | DigitalOcean unable to load CA private key.. | DigitalOcean Add additional billing contact | DigitalOcean Digital Ocean Cloud Firewall? | DigitalOcean Mongodb auditing and compliance | DigitalOcean How much you're spending on AI tools? | DigitalOcean I can't create a managed MySQL cluster | DigitalOcean Please unblock SMTP (ports 25/465/587) for my droplet | DigitalOcean Reported promotional profile still accessible on DigitalOcean | DigitalOcean Change DNS server on Ubuntu 24 | DigitalOcean cannot add promotion of github student pack | DigitalOcean Do I need to use a Load Balancer on DigitalOcean for HTTPS or can I handle it on the Droplet? | DigitalOcean Best way to deploy a small Docker app on DigitalOcean without overengineering? | DigitalOcean Why is my DigitalOcean Droplet bandwidth usage so high all of a sudden? | DigitalOcean smtpout.secureserver.net 587 is blocked | DigitalOcean How do I disable AI? | DigitalOcean
How to fix website not loading issue on VPS server (Nginx...
By 511c1785d2404350b53231089c0190 · 2026-04-07 · via DigitalOcean Community Questions

Heya,

When you get a 502 Bad Gateway error, the problem is usually not Nginx itself. Most of the time, Nginx is working, but it cannot get a valid response from the backend service it depends on, which is usually PHP-FPM for WordPress.

For a WordPress site on Nginx + Ubuntu 22.04, the most common causes are:

  • PHP-FPM is down or stuck
  • Wrong PHP-FPM socket/path in the Nginx config
  • PHP worker exhaustion from heavy traffic, bad plugins, or slow requests
  • Timeouts caused by a slow plugin, theme, or external API call
  • Low server memory, causing PHP-FPM or MySQL to crash
  • Less commonly, database issues can make WordPress hang, even if they do not directly trigger every 502

To troubleshoot it, first check the Nginx error log:

sudo tail -f /var/log/nginx/error.log

Or review recent lines with:

sudo tail -n 50 /var/log/nginx/error.log

That log usually tells you whether Nginx failed to connect to PHP-FPM, hit a timeout, or found a bad upstream definition.

Since WordPress runs through PHP, the next important step is to check PHP-FPM logs and status.

First, see which PHP version is installed:

php -v

Then check the PHP-FPM service:

sudo systemctl status php8.1-fpm

On Ubuntu 22.04, the PHP-FPM log is often here:

sudo tail -n 50 /var/log/php8.1-fpm.log

You can also inspect the system journal:

sudo journalctl -u php8.1-fpm -n 50 --no-pager

If PHP-FPM is stopped or failing, restart it:

sudo systemctl restart php8.1-fpm

Also confirm that Nginx is pointing to the correct PHP socket. In your Nginx site config, look for something like:

fastcgi_pass unix:/run/php/php8.1-fpm.sock;

If Nginx points to the wrong PHP version or a missing socket, you can get intermittent 502 errors immediately.

After that, check WordPress/application-level logs. For WordPress, enable debugging in wp-config.php:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Then review:

tail -n 50 /path/to/wordpress/wp-content/debug.log

That helps catch plugin, theme, and PHP fatal errors that do not always appear clearly in the browser.

It is also worth checking whether the server is running out of memory:

free -h
dmesg -T | grep -i -E 'killed process|out of memory'

If PHP-FPM workers are being killed by the OOM killer, the site may alternate between hanging and returning 502.

A practical fix checklist would be:

  1. Check nginx/error.log
  2. Check php-fpm service status and logs
  3. Verify the fastcgi_pass socket/path in Nginx
  4. Enable WordPress debug logging
  5. Check memory usage and OOM events
  6. Temporarily disable heavy or recently added plugins
  7. Reload services after changes:
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl restart php8.1-fpm