iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
A 502 Bad Gateway on a WordPress site running behind Nginx means Nginx could not obtain a usable response from its upstream, normally PHP-FPM. The reliable fix is to identify the exact error-log signature, verify that PHP-FPM is running and listening where Nginx expects it, then check capacity, database/cache dependencies, and the specific WordPress request. Do not start by increasing timeouts: a missing socket, crashed PHP worker, permission error, or exhausted backend will not be repaired by waiting longer.
What a 502 means in an Nginx WordPress stack
Nginx is the gateway in this arrangement. It serves static files and forwards dynamic PHP requests to PHP-FPM through either a Unix socket or a TCP listener. The Nginx fastcgi_pass value must match the PHP-FPM pool’s listen directive exactly. If Nginx cannot connect, cannot receive response headers, or receives a connection that closes unexpectedly, it returns 502 to the browser.
The browser-facing error page does not identify the failing component. BOA’s troubleshooting documentation describes 502 and 504 responses as Nginx reports that are almost always caused downstream, such as PHP-FPM, MySQL, Valkey/Redis, or the application itself. Treat the status code as a routing symptom, not a diagnosis.
Capture the failure before changing anything
- Reproduce the problem once. Record the complete URL, HTTP method, approximate UTC time, logged-in state, and whether the failure affects the whole site, only
/wp-admin, the REST API,admin-ajax.php, or one public route. - Open a second request in a private browser window or with a command-line client. This distinguishes a user-session or cache problem from a server-wide failure.
- Note whether the response is consistently 502, changes to 504, redirects repeatedly, or succeeds intermittently. Intermittent failures often indicate worker or memory pressure rather than a permanently wrong path.
- Do not reload Nginx or restart PHP-FPM before collecting at least one timestamped log entry unless the site is in an active outage and you have an approved recovery procedure. A restart can erase the evidence of a crash or queue buildup.
Read Nginx and PHP-FPM logs first
NGINX documentation calls logging essential for understanding how traffic moves through infrastructure. The error-log location depends on the installation; a common Linux path is /var/log/nginx/error.log. Use the configured path if your distribution or hosting panel stores logs elsewhere.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
sudo tail -n 100 /var/log/nginx/error.log
sudo tail -f /var/log/nginx/error.log
In a second terminal, locate the PHP-FPM service and its logs. Service names vary by distribution and installed PHP package, so list candidates rather than assuming one versioned name.
systemctl list-units --type=service | grep -i fpm
sudo systemctl status php-fpm
sudo journalctl -u php-fpm --since "15 minutes ago"
If your service is versioned, substitute its actual name, such as php8.2-fpm. Correlate Nginx and PHP-FPM entries by timestamp. A PHP fatal error, worker termination, out-of-memory event, or pool-limit warning at the same moment is more useful than the generic 502 page.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Use the log wording to choose the next check
| Nginx signature | What it usually means | First action |
|---|---|---|
connect() failed (111: Connection refused) |
No process is accepting connections on the configured socket or TCP port, or a firewall/security policy is rejecting the connection. | Check PHP-FPM state, then verify the listener and service logs. |
connect() failed (2: No such file or directory) |
The Unix-socket path in fastcgi_pass does not exist. PHP-FPM may be stopped, using another path, or creating the socket in a different runtime directory. |
Compare the Nginx target with the pool’s listen value and confirm the file exists. |
upstream timed out |
The backend did not connect or return headers/body within the configured interval. Slow PHP code, a saturated pool, database latency, or a blocked external call are common causes. | Inspect PHP-FPM queue/worker limits, memory, database and cache latency before changing timeout values. |
upstream sent too big header |
The response headers exceed Nginx’s configured FastCGI buffer capacity. Large cookie sets or plugin-generated headers can trigger it. | Identify the endpoint and header source; remove unnecessary cookies/headers before increasing buffers cautiously. |
upstream prematurely closed connection |
PHP-FPM or the application closed the connection before Nginx received a complete response, often after a fatal error, crash, forced termination, or memory kill. | Check PHP-FPM, PHP, kernel, and application logs for the matching timestamp. |
Verify that PHP-FPM is running and listening
Check service health
sudo systemctl is-active php-fpm
sudo systemctl status php-fpm --no-pager
sudo journalctl -u php-fpm -b --no-pager | tail -n 100
An inactive or failed service explains a connection-refused error. Read the failure reason before restarting. Configuration syntax errors, an occupied socket, a missing directory, or a permission problem should be corrected first.
After a verified correction, restart only the affected service and immediately retest the original URL:
sudo systemctl restart php-fpm
curl -I https://example.com/
Replace the example hostname with your site. A restart is a recovery step, not proof that the underlying cause is fixed; if workers fail again, return to the service log.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Find the pool’s listener
PHP-FPM pool files commonly live below /etc/php/*/fpm/pool.d/, /etc/php-fpm.d/, or a hosting-panel-specific directory. Search the active configuration for listen:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →sudo grep -R "^[[:space:]]*listen[[:space:]]*=" /etc/php /etc/php-fpm.d 2>/dev/null
The value may be a Unix socket such as /run/php/php-fpm.sock or a TCP endpoint such as 127.0.0.1:9000. Now inspect the Nginx server block that handles the failing host and find fastcgi_pass:
sudo nginx -T | grep -n "fastcgi_pass|server_name"
Make the two targets identical, including the full socket path, IP address, and port. Do not change one side by guesswork. A socket with a similar filename, a different PHP version, or a relative path is still a mismatch.
Confirm the socket or TCP port exists
For a Unix socket, check the file and its parent directory:
sudo ls -l /run/php/php-fpm.sock
sudo namei -l /run/php/php-fpm.sock
The socket must exist after PHP-FPM starts. Nginx’s worker user needs permission to traverse every parent directory and connect to the socket. The pool’s listen.owner, listen.group, and listen.mode settings control this on many installations. Align them with the Nginx worker account instead of making the socket world-writable.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
For a TCP listener, verify that a process is bound to the expected address and port:
sudo ss -ltnp | grep ':9000'
Use the port shown in your pool configuration. If PHP-FPM listens only on 127.0.0.1, Nginx on the same host can use it; a container or separate host requires the appropriate reachable address and network policy. Keep the listener private unless there is a deliberate, secured architecture requiring otherwise.
Validate Nginx safely before reloading
After editing a server block or changing fastcgi_pass, keep a rollback copy and test the complete configuration:
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup-$(date +%Y%m%d-%H%M%S)
sudo nginx -t
Proceed only when the test reports that the syntax is successful and the configuration test is successful. Then reload rather than stopping the service:
sudo systemctl reload nginx
If nginx -t fails, do not reload. Restore the known-good file or correct the reported include, brace, path, or directive error. A failed reload leaves the existing worker configuration in place, while an unvalidated restart can turn a 502 into a complete web-server outage.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
When the error is a timeout, investigate workload and capacity
An upstream timed out entry means the request took too long at a particular stage; it does not automatically mean Nginx’s timeout is too short. Increasing fastcgi_read_timeout can merely keep more requests waiting while PHP-FPM workers, memory, or the database remain saturated.
- Check PHP-FPM pool limits such as
pm.max_children,pm.max_requests, and the selected process manager mode. A full pool leaves new requests queued or rejected. - Look for warnings that the pool has reached its maximum children, and compare that with CPU, RAM, and swap usage.
- Inspect the database for slow queries, connection exhaustion, locks, or a database service restart at the failure time.
- Check Valkey/Redis or another object-cache service if WordPress depends on it. An unavailable cache can cause slow fallback queries or application errors.
- Review scheduled tasks, backup jobs, imports, image processing, and external API calls that may consume workers.
free -h
uptime
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
sudo journalctl -k --since "15 minutes ago" | grep -i "oom|killed process"
Kernel out-of-memory messages, repeated worker exits, or a steadily growing queue indicate a capacity or application problem. Reduce the expensive workload, fix the query or plugin task, or size the pool for available memory before adjusting gateway timeouts.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Separate a site-wide failure from a WordPress endpoint failure
Every dynamic URL returns 502
Prioritize the infrastructure path: PHP-FPM state, listener agreement, socket permissions, and host memory. Test a lightweight PHP endpoint and a normal WordPress page separately. If both fail with the same connection error, changing a theme or plugin is unlikely to help.
Only the WordPress dashboard, REST API, or AJAX fails
A scoped failure points toward application code, authentication hooks, scheduled work, or a request-specific dependency. Use the exact failing path and method in your reproduction notes. Inspect PHP and WordPress logs at that timestamp, then disable or roll back the most recent plugin, theme, configuration, or scheduled task through a controlled process.
If dashboard access is unavailable, use an approved administrative route such as a deployment rollback or command-line WordPress management tool already installed on the server. Do not delete plugin directories or edit production data blindly. Change one component at a time, retest the same request, and record which change altered the result.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Only one public URL fails
Compare that route with a simple page and examine its query volume, uploaded data, redirect behavior, and application logs. A single expensive report, search, import, or uncached page can exhaust PHP workers while the rest of the site remains healthy. Fix the request or its code path rather than raising global limits for every visitor.
Check dependencies before blaming Nginx
WordPress PHP code can fail when its database, object cache, filesystem, or external service is unavailable. Check each dependency from the same host and network context used by PHP-FPM:
- Confirm the database service is running, accepting local connections, and not reporting connection-limit or storage errors.
- Check disk space and inode availability. PHP sessions, temporary uploads, logs, and cache writes can fail when either is exhausted.
- Verify that WordPress directories and files are writable only where required, while PHP-FPM can read the application and write its designated upload/cache paths.
- Inspect DNS and outbound connectivity if the failing request calls an external API. A blocked or slow remote call can hold a PHP worker until Nginx times out.
- Check cache-service logs and credentials when object caching is enabled; a cache outage should not be mistaken for a broken FastCGI socket.
df -h
df -i
sudo systemctl status mysql
sudo systemctl status redis
Service names differ, and a site may use a different database or cache product. Run status commands only for components actually present in your deployment.
Use timing variables to locate the delay
Nginx can log $upstream_connect_time, $upstream_header_time, $upstream_response_time, and $request_time. Add them to a temporary access-log format if they are not already present, then correlate a failing request by timestamp.
- A zero or missing connect time can indicate that Nginx never reached the upstream, consistent with a missing socket or refused connection.
- A long connect time points to difficulty establishing the backend connection.
- A short connect time followed by a long header time suggests PHP code, a database query, or another dependency delayed the first response header.
- A long response time after headers begin indicates slow response generation or transfer.
Interpret these values with the corresponding error-log line; a timing value alone cannot identify which PHP function or query is slow.
Enable Nginx debug logging only as a controlled escalation
NGINX documents that debug logging is disabled by default and requires a build compiled with debug support. If ordinary error and application logs do not explain the failure, a qualified administrator can temporarily set:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
error_log /var/log/nginx/error.log debug;
Validate with nginx -t, reload, reproduce the problem once or for a short window, and collect the relevant lines. Debug logs can grow very large and affect performance. Revert to the previous log level immediately after collection, validate again, and reload. Never leave debug logging enabled during normal traffic without a specific operational reason.
Quick Recap
Prevent the next 502
- Keep the Nginx
fastcgi_passtarget and PHP-FPM poollistenvalue under configuration management so a PHP upgrade cannot silently change one side. - Monitor PHP-FPM worker utilization, child-reached-limit warnings, memory, disk space, database latency, and cache availability.
- Retain Nginx, PHP-FPM, PHP, database, and kernel logs long enough to correlate an incident across services.
- Test plugin, theme, PHP, and server changes in a staging environment or with a rollback plan.
- Use health checks that exercise a lightweight PHP request and a representative WordPress request, not just Nginx’s static response.
- Document the service names, socket path, pool file, Nginx server block, worker user, and rollback commands for the site.
A concise recovery checklist
- Capture one reproducible failing request and its timestamp.
- Read the Nginx error log and matching PHP-FPM/application logs.
- Classify the signature as connection failure, timeout, oversized header, or premature close.
- Confirm PHP-FPM is active and its listener exists.
- Make
fastcgi_passexactly match the pool’slistentarget and verify socket permissions. - Check memory, worker limits, database, cache, disk, and external dependencies before increasing timeouts.
- If only one WordPress endpoint fails, isolate the latest plugin, theme, task, or request-specific workload.
- Run
nginx -t, keep a rollback copy, reload safely, and retest the original URL. - Use debug logging briefly only when normal logs cannot distinguish the remaining causes.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

