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
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
FastCGI errors are failures in the conversation between a web server and an application process such as PHP-FPM. A 502 Bad Gateway, “connect() failed while connecting to upstream,” a missing socket, or a timeout each points to a different stage of that conversation. Capture the exact log line first, then verify that PHP-FPM is running, make the configured endpoint match the listener, correct socket permissions, and investigate application capacity before raising a timeout.
What a FastCGI error means
FastCGI is the interface that lets Nginx or Apache pass a request to a long-running application service. For PHP sites, that service is commonly PHP-FPM. The web server accepts the browser request, selects a script, sends request metadata and (when needed) a request body to PHP-FPM, waits for headers and content, and returns the result to the browser.
Recommended Free Tools
An error can occur at any of those stages:
- Connection stage: the server cannot open a TCP connection or Unix-domain socket.
- Send stage: the connection exists, but the request cannot be delivered.
- Read stage: the backend does not return data within the configured interval.
- Response stage: the backend closes the connection or sends invalid FastCGI headers.
- Application stage: PHP starts but fails, hangs, exhausts workers, or encounters a database or code error.
The same browser symptom can result from different stages. Treat the complete web-server log entry—not only “502 Bad Gateway”—as the diagnosis starting point.
First response: capture and classify the exact error
Reproduce the failing URL once while watching the relevant error log. Preserve the upstream address, socket path, port, errno text, and wording such as “while connecting,” “while sending,” or “while reading response header.” Those details determine which check comes next.
#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.
Nginx logs
sudo tail -f /var/log/nginx/error.log
On systems that use systemd or a custom log path, use the location configured in the Nginx error_log directive. A message such as connect() to unix:/run/php/php-fpm.sock failed (2: No such file or directory) identifies an endpoint or service-path problem. Connection refused usually means that nothing is accepting connections at the configured address, or that the listener has reached a condition where it refuses new work. A message that names while reading response header from upstream points to backend processing, capacity, or a read limit rather than a missing listener.
Apache logs
sudo tail -f /var/log/apache2/error.log
Distribution paths vary; use the Apache virtual-host configuration if the error log is elsewhere. Record the PHP-FPM host, port, or socket shown in the proxy error, and note whether Apache reports a connection failure, a timeout, or an invalid response.
Use the classification to choose the next check
| Log evidence | Most likely area | First check |
|---|---|---|
| Connection refused | PHP-FPM stopped, wrong address or port, listener saturation, or firewall policy | Confirm the service and its listening endpoint |
| No such file or directory for a Unix socket | Socket path differs from the pool configuration, or the service has not created it | Inspect the actual socket and PHP-FPM pool file |
| Permission denied opening a socket | Web-server worker cannot access the socket or one of its parent directories | Check owner, group, mode, and directory traversal permissions |
| Timeout while connecting | Unreachable endpoint, overloaded listener, or network path problem | Test the address and inspect backend capacity |
| Timeout while reading | Slow PHP code, database or external call, blocked worker, or too-short read interval | Inspect PHP-FPM and application timing before changing limits |
| Invalid or incomplete upstream headers | PHP-FPM crashed, was killed, or emitted an invalid response | Read PHP-FPM and application logs at the same timestamp |
Verify that PHP-FPM is alive and listening
Do not change browser settings for a refused connection or missing socket. Check the backend process first.
Check service state
sudo systemctl status php-fpm
sudo systemctl status php8.2-fpm
The service name depends on the operating system and installed PHP version. Use the name shown by your package manager if neither command exists. If the service is stopped, inspect its journal before starting it:
sudo journalctl -u php-fpm --since "15 minutes ago"
sudo journalctl -u php8.2-fpm --since "15 minutes ago"
Look for configuration parse errors, missing directories, exhausted resources, or a pool that failed to start. Correct the underlying error, then restart or start the service and reproduce the request.
Inspect TCP listeners
sudo ss -ltnp | grep ':9000'
Replace 9000 with the port configured in the PHP-FPM pool. A healthy listener must be on an address reachable from the web-server process. A pool bound only to a different loopback address, a private interface, or IPv6 can be unreachable when the web server uses another address family.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Inspect Unix-domain sockets
sudo find /run /var/run -type s -name '*php*' -ls 2>/dev/null
Compare the discovered path with the pool’s listen setting and the web server’s upstream directive. A socket is created only after its pool starts successfully; an absent file can therefore indicate a stopped pool or a path mismatch rather than a filesystem deletion.
Test the endpoint from the server
For TCP, verify that the port is reachable from the machine running Nginx or Apache:
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
nc -vz 127.0.0.1 9000
This confirms that a TCP listener accepts a connection; it does not by itself prove that PHP returns a valid response. For a Unix socket, inspect the file and permissions instead of trying to use an HTTP client against it.
Fix Nginx FastCGI configuration
Nginx’s FastCGI integration is provided by ngx_http_fastcgi_module. The two settings that most often get out of sync are fastcgi_pass, which identifies the backend endpoint, and fastcgi_param SCRIPT_FILENAME, which identifies the script PHP should execute.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Make fastcgi_pass match PHP-FPM
Use a TCP address when the pool listens on TCP:
location ~ .php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Use the exact Unix socket path when the pool listens on a socket:
location ~ .php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
The example paths are not universal. PHP package versions and pool names commonly create different filenames, so copy the path from the active pool configuration rather than assuming that a file with a similar name is correct. Do not use a TCP directive for a socket or a socket directive for a TCP listener.
Resolve the script identity
SCRIPT_FILENAME must resolve to the real filesystem path of the requested PHP file. If the document root is /srv/www/site/public, a request for /index.php should produce /srv/www/site/public/index.php. A wrong root can produce “primary script unknown,” a 404-like response, or an application failure even though the FastCGI connection itself works.
sudo nginx -T | less
Review the complete, expanded configuration rather than only the file you last edited. Another server block, an included snippet, or a more specific location can override the directive you are inspecting.
Pass the request parameters PHP needs
For ordinary PHP requests, include the distribution’s FastCGI parameter file or define the required parameters explicitly. POST requests in particular need the request method, content type, and content length passed through:
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
Use the parameter names and values expected by your Nginx version and PHP-FPM setup. Omitting them can make a form submission behave differently from a simple GET while leaving the socket connection apparently healthy.
Rank #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.
Validate before reloading
sudo nginx -t
sudo systemctl reload nginx
If the test fails, Nginx keeps its previous configuration; fix the reported file and line before reloading. A reload applies configuration without unnecessarily terminating existing workers. Restart only when a service-level change requires it.
Fix Apache FastCGI proxying
Apache commonly reaches PHP-FPM through mod_proxy together with mod_proxy_fcgi. Some installations use mod_fcgid instead; do not mix directives from those modules without checking which integration is enabled.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Confirm the required modules
sudo apachectl -M | grep -E 'proxy_module|proxy_fcgi_module|fcgid_module'
On systems that provide module-management commands, enable the modules there and reload Apache. A proxy rule cannot work when the module that implements its scheme is not loaded.
Point the proxy at the real PHP-FPM endpoint
A TCP backend rule must name the same host and port as the PHP-FPM pool. A common pattern is:
ProxyPassMatch "^/(.*.php)$" "fcgi://127.0.0.1:9000/var/www/site/public/"
Adjust the URL and filesystem prefix to your virtual host. The prefix determines how Apache maps the requested script; a mismatch can connect successfully yet execute the wrong path. For a Unix socket, use the socket form documented for the installed Apache mod_proxy_fcgi version and ensure the path is the one created by PHP-FPM. Socket syntax and support details vary by version, so do not copy a TCP URL and merely replace its port.
Understand connection reuse
Apache’s FastCGI proxy can reuse backend connections in configurations that opt in to reuse. Reuse is appropriate only when the FastCGI application can safely handle concurrent reused connections. If PHP-FPM or another backend is not configured for that behavior, disable reuse according to the module’s directives rather than treating every reuse-related error as a timeout problem.
Free tools Windows power users keep installed
One-click scans. No signup required.
Check and reload Apache
sudo apachectl configtest
sudo systemctl reload apache2
Use httpd instead of apache2 where that is the service name. Resolve syntax errors before reloading. Then watch the Apache error log while making one fresh request.
Correct socket ownership and permissions
A socket can exist and still be unusable. The worker account running Nginx or Apache needs permission to open the socket and traverse every parent directory.
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.
Inspect the complete path
namei -l /run/php/php-fpm.sock
ls -l /run/php/php-fpm.sock
namei reveals permissions on each directory component. Check the account under which the web server runs in its service configuration, commonly shown by the Nginx user directive or Apache’s service settings.
Align the PHP-FPM pool
PHP-FPM pool settings normally provide socket owner, group, and mode controls. Set the group to one that includes the web-server account, or use an appropriate owner and mode policy for your host. Change only the relevant pool and avoid making the socket world-writable. After editing the pool, restart PHP-FPM so it recreates the socket with the new metadata, then reload the web server if its endpoint changed.
sudo systemctl restart php-fpm
sudo systemctl reload nginx
Package upgrades, pool renames, and runtime-directory cleanup can recreate a socket with a different path or mode. Record the setting in configuration management and verify it after upgrades rather than applying a temporary chmod that will disappear at the next restart.
Diagnose timeouts by phase
Nginx has separate controls for connecting to the backend, sending the request, and reading the response:
| Directive | What it limits | What an expiry suggests |
|---|---|---|
fastcgi_connect_timeout |
Time allowed to establish the FastCGI connection | Wrong route, unavailable listener, network issue, or saturated backend |
fastcgi_send_timeout |
Time between writes while sending request data | Backend or network is not accepting data, or a large upload is blocked |
fastcgi_read_timeout |
Time between reads while waiting for the backend response | Slow code, a blocked database or external call, exhausted workers, or an interval that is too short |
These are inactivity intervals, not a promise that the entire request may run for exactly that many seconds. Raising a limit can hide a saturated pool and tie up more web-server workers. First establish that the operation is expected to be long-running, identify its slow dependency, and confirm that PHP-FPM has enough workers and memory.
Check PHP-FPM capacity
Review the pool’s process-manager settings, active and idle workers, slow-request log, and recent restarts. If all workers are busy, requests queue until the web server’s read interval expires. Increasing the pool limit without checking available memory can replace timeouts with swapping or out-of-memory kills. Compare worker counts with the host’s memory budget and the application’s observed peak usage.
Check the application path
Correlate the web-server timestamp with PHP-FPM, PHP, and application logs. A slow SQL query, an unavailable remote API, a lock, or a fatal error can prevent headers from being returned. Fix that operation or add an application-level limit before changing Nginx or Apache timeouts. Test a static file and a minimal PHP script separately to distinguish a server-wide problem from one route.
Apache connection and process controls
Apache’s FastCGI modules expose their own connection and process-lifetime settings. Identify which module is active and change the corresponding directives; an Nginx timeout setting has no effect on an Apache request. Apply a larger value only after measuring the expected operation and confirming backend health.
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.
Understand retries and incomplete responses
Nginx’s fastcgi_next_upstream can try another eligible upstream after connection errors, timeouts, denied connections, or invalid headers. It cannot repair a response after Nginx has already sent part of that response to the client. A retry is therefore a limited availability mechanism, not a cure for a broken PHP-FPM pool or a failing application.
Retries can also repeat a request. Be cautious with non-idempotent operations such as payments, account changes, or form submissions; confirm that the application and upstream policy make repetition safe. When a request has already produced response bytes, correct the backend or application rather than adding more retry conditions.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCommon symptoms and targeted fixes
“502 Bad Gateway” immediately after deployment
- Read the Nginx or Apache error log at the failure time.
- Compare the deployed configuration’s endpoint with the active PHP-FPM pool.
- Run the configuration test and verify that the new pool actually started.
- Check whether a release changed the document root, causing an incorrect
SCRIPT_FILENAMEor Apache path prefix.
“connect() failed while connecting to upstream”
Confirm that the listener exists at the exact address and port or socket path. A refused TCP connection calls for service and listener checks; a missing Unix socket calls for pool status and path comparison. Do not increase fastcgi_read_timeout; the request has not reached the read stage.
“No such file or directory” for a PHP-FPM socket
Find the socket PHP-FPM created, compare it with fastcgi_pass or Apache’s backend URL, and inspect the pool’s listen setting. Start or restart the correct pool if no socket exists. If the socket is created under a runtime directory that is cleaned at boot, ensure the service creates that directory before starting.
“Permission denied” for a socket
Inspect every parent directory and the socket’s owner, group, and mode. Make the web-server account a member of the intended group or adjust pool ownership, then restart PHP-FPM so the socket is recreated. Avoid broad permissions that expose the application to unrelated local users.
“upstream timed out while reading response header”
Check PHP-FPM worker utilization, slow-request records, database latency, and application logs. If the operation is valid but predictably slow, raise the read or process limit modestly and monitor worker occupancy. If the operation is unexpectedly slow, fix it instead of extending the limit indefinitely.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPHP-FPM is running but the site still fails
Verify that the web server reaches the same pool you inspected. Multiple PHP versions can create multiple sockets or ports. Check the active virtual host, included configuration, container or chroot boundaries, and the account used by the web-server workers. Then test a minimal script and the failing application route independently.
Nginx and Apache: what differs
| Area | Nginx | Apache |
|---|---|---|
| FastCGI integration | ngx_http_fastcgi_module |
mod_proxy with mod_proxy_fcgi, or mod_fcgid |
| Backend address | fastcgi_pass to a TCP address or Unix socket |
FastCGI backend URL for the PHP-FPM host, port, or supported socket form |
| Script identity | fastcgi_param SCRIPT_FILENAME plus request parameters |
Proxy mapping and PHP-FPM environment parameters |
| Timeout controls | fastcgi_connect_timeout, fastcgi_send_timeout, and fastcgi_read_timeout |
Module-specific connection and process-lifetime settings |
| Retry behavior | fastcgi_next_upstream for eligible failures before response data is sent |
Determined by the proxy and backend configuration |
The diagnostic order is the same for both servers: capture the exact error, verify the backend, align the endpoint, fix permissions, validate script mapping, and investigate capacity before changing time limits.
After the fix: verify and prevent recurrence
- Run the web-server configuration test and reload the affected service.
- Make one request to a minimal PHP endpoint, then the previously failing URL.
- Watch the error log and PHP-FPM log during both requests.
- Confirm that the response status, headers, and body are complete rather than merely free of a connection error.
- Record the active socket or port, pool name, owner and group, document root, and timeout rationale.
- Add monitoring for PHP-FPM restarts, worker saturation, socket disappearance, and recurring upstream timeouts.
Keep Nginx or Apache configuration, PHP-FPM pool files, and runtime assumptions together in deployment management. When a PHP version, package, virtual host, or container changes, verify the endpoint and socket permissions as part of the rollout instead of waiting for a 502 report.
A compact decision checklist
- Exact message captured? Include stage, errno, endpoint, and timestamp.
- Backend running? The correct PHP-FPM pool is active and its logs show no startup failure.
- Listener aligned? TCP host and port or Unix socket path match exactly.
- Socket usable? The web-server account can traverse directories and open the socket.
- Script path correct? Nginx’s
SCRIPT_FILENAMEor Apache’s mapping points to the intended file. - Request parameters present? Method, content type, and content length are passed for requests that need them.
- Timeout explained? Capacity and application behavior were checked before increasing a limit.
- Retry appropriate? No policy relies on retries to repair a response that has already begun or to repeat unsafe writes.
Following this sequence turns a generic FastCGI 502 into a specific service, endpoint, permission, configuration, or application problem—the level at which it can be fixed permanently.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
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.

