Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

A 504 from NGINX means the gateway did not complete communication with its upstream within the applicable timeout window. The quickest way to find the cause is to identify which phase stalled: opening the upstream connection, waiting for response headers, or waiting between response-body reads. Start with the NGINX error log and upstream timing fields, then test the backend directly from the NGINX host. Increase proxy_read_timeout only when the backend is healthy and deliberately silent for longer than its current idle-read interval.

What a 504 Gateway Timeout means in NGINX

In a reverse-proxy setup, a client sends a request to NGINX and NGINX forwards it to an upstream application server, service, or load balancer. NGINX returns HTTP status 504 when it cannot complete that upstream exchange before a relevant timeout expires. The status identifies a failed gateway-to-upstream interaction; it does not, by itself, prove that the application is down.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Three stages matter when diagnosing the failure:

  • Connection establishment: NGINX cannot establish a TCP connection to the configured upstream in time.
  • Response-header wait: the connection succeeds, but the upstream does not send response headers within the read interval.
  • Response-body read gap: the upstream has started responding, then remains silent between successive reads for longer than allowed.

These stages can have very different causes. A connection failure commonly involves DNS, routing, firewall rules, a closed listener, a wrong port, or exhausted backend capacity. A long header wait more often indicates application startup, worker exhaustion, a lock, a slow database query, or another dependency. A body-read gap may be normal for a streaming endpoint or may indicate that the upstream has stalled.

Do not treat every 504 as a request-duration problem. NGINX has separate connect, read, and send timeout concepts, and the limits imposed by other proxies, load balancers, application servers, and clients may be different.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • 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: 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.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Capture the exact failing request first

Before changing configuration, record enough information to reproduce one failure and distinguish an intermittent problem from a deterministic one.

  • UTC timestamp, including seconds and preferably milliseconds.
  • Request host, URI, HTTP method, query string, and status code.
  • Request or trace ID, if your application adds one.
  • Whether the request always fails, fails only under load, or fails after a particular elapsed time.
  • Relevant request headers, authentication context, and body size (without exposing credentials in tickets or logs).
  • The NGINX server, upstream name, and upstream address selected for that request.

Correlate this record across NGINX, the application, and database logs. A request ID is especially useful: if NGINX reports a timeout but the application never logs the request, investigate routing or connection establishment; if the application logs a request that runs for a long time, investigate its processing path and dependencies.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read the NGINX error log before changing settings

NGINX’s error log records operational events by severity. The exact path depends on how NGINX was installed and configured; a common package installation uses /var/log/nginx/error.log. Check the active configuration rather than assuming a path:

nginx -T 2>&1 | less

Search the output for error_log directives and for the server or location handling the failing host. Then inspect entries around the captured timestamp:

sudo grep -n "2026/10/15" /var/log/nginx/error.log | tail -n 50
sudo tail -f /var/log/nginx/error.log

Use the date pattern appropriate for your log format. Typical messages identify the upstream address and whether NGINX timed out while connecting, reading response headers, or reading response data. Preserve the complete line when escalating; the operation named in the message is often the first reliable indication of the failing phase.

If the configured error-log level is too low to show useful detail, temporarily raise it only for the affected context when possible. A broad production-wide change can create unnecessary volume. Debug logging is an escalation step, not a permanent setting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add upstream timing fields to the access log

Error-log text tells you what NGINX noticed. Access-log timing fields show how long each part of the exchange took. NGINX defines these variables as follows:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • 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
Variable What it measures Diagnostic use
$upstream_connect_time Time to connect to the upstream High or missing values point toward DNS, routing, firewall, listener, port, or capacity problems.
$upstream_header_time Time until the first response-header byte is received A long interval after a normal connection points toward application work or a dependency delaying the first response.
$upstream_response_time Time until the last response-body byte is received Compare with header time to find a slow body or pauses after the response starts.
$request_time Total request-processing time in NGINX Shows the client-visible duration and includes proxying overhead.

Define a temporary or permanent log format that includes all four values. Add it in the HTTP configuration context, then select it with access_log in the relevant server or location:

log_format upstream_timing '$remote_addr - $host [$time_iso8601] '
                          '"$request" $status '
                          'rt=$request_time '
                          'uct=$upstream_connect_time '
                          'uht=$upstream_header_time '
                          'urt=$upstream_response_time '
                          'req_id=$request_id';

access_log /var/log/nginx/access_upstream_timing.log upstream_timing;

Validate and reload safely:

sudo nginx -t
sudo systemctl reload nginx

Variable values can be absent or contain multiple comma-separated values when a request tries more than one upstream server. Keep the upstream-selection behavior in mind when comparing lines. For a 504, compare the timing values with the error-log message and with a successful request for the same endpoint.

Use the timing pattern to locate the failing phase

Pattern 1: connection establishment fails or takes too long

If $upstream_connect_time is high, missing, or accompanied by a connect-timeout message, test name resolution and network reachability from the NGINX machine. A backend can be healthy from one network segment and unreachable from another.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Confirm that the upstream hostname resolves to the expected address from the NGINX host.
  • Confirm that the configured port is the port on which the application is listening.
  • Check host, container, and cloud security rules, including egress rules from NGINX and ingress rules at the backend.
  • Check routing, service discovery, and recent address changes.
  • Inspect backend connection limits, accept queues, and process or container capacity.

A larger read timeout cannot repair a refused connection or a packet path that never completes. Fix the address, route, firewall, listener, or capacity problem first.

Pattern 2: connection succeeds but headers are delayed

A normal connection time followed by a long $upstream_header_time means NGINX reached the upstream but did not receive the first response-header byte promptly. Investigate work that happens before the application can emit headers:

  • Application startup, cold initialization, or just-in-time compilation.
  • Exhausted application workers, threads, event-loop capacity, or request queues.
  • Locks, deadlocks, or contention on shared resources.
  • Slow database queries, connection-pool exhaustion, or blocked transactions.
  • Calls to another service, DNS lookup, storage system, or external dependency.

Check application and database metrics for the same request window. If the application records the request and shows a long internal span, fix that operation or its dependency rather than merely allowing NGINX to wait longer.

Pattern 3: headers arrive, then body reads pause

When header time is acceptable but the final response takes much longer, the upstream began responding and then stopped sending data for an interval. This can be legitimate for streaming, long-polling, report generation, or server-sent events, but it can also mean a stalled worker or dependency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【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.

Look at the endpoint’s response behavior and the application logs. Determine whether the endpoint intentionally emits data periodically. If it does, every gap between reads must remain within the configured read timeout (or the application must send keep-alive data). If it does not, investigate why the producer stopped after sending headers or part of the body.

Test the upstream directly from the NGINX host

Make a direct request from the same NGINX machine, container, or network namespace. Use the upstream host and port from the active NGINX configuration, not the public hostname that may take a different route.

curl -v --connect-timeout 10 
     --max-time 120 
     -o /dev/null 
     -w 'connect=%{time_connect} start=%{time_starttransfer} total=%{time_total}n' 
     http://UPSTREAM_HOST:UPSTREAM_PORT/path

Replace the placeholders with the real upstream endpoint. Reproduce the original method, headers, authentication context, and body when they affect application behavior. For example, a POST that triggers a database operation is not equivalent to a GET of a health endpoint. Do not copy authorization tokens into shell history or shared tickets.

Compare direct and proxied results:

Direct request result Likely direction Next check
Cannot connect or resolve Network, DNS, listener, port, firewall, or backend capacity Resolve the connectivity fault from the NGINX network context.
Connects but waits before headers Application or dependency latency Inspect worker queues, database calls, locks, and downstream services.
Direct request is fast, proxied request times out NGINX routing, proxy settings, intermediary, or request transformation Compare selected upstream, headers, body, buffering, and every hop’s limits.
Both direct and proxied requests pause in the body Backend behavior or intentional streaming Check response cadence and idle-read requirements.

Run more than one controlled request if the failure is intermittent, and avoid generating load against a saturated production backend.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand NGINX timeout directives and the end-to-end budget

NGINX Gateway Fabric documents independent connect, read, and send timeouts. These are not interchangeable. A request may pass one limit and fail another, and a client-facing proxy or load balancer may terminate the request earlier than NGINX.

  • Connect timeout: the time allowed to establish communication with the upstream.
  • Read timeout: the permitted interval while NGINX waits for data from the upstream.
  • Send timeout: the permitted interval while NGINX sends data to the upstream.

Read and send values are intervals between operations, not necessarily total transfer limits. A large response can take longer than the configured read value if it continually produces data before each interval expires. Conversely, a short response can fail when the upstream remains silent for one idle interval.

Map the complete request path before choosing values:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【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.
  1. Client or browser timeout.
  2. CDN, edge proxy, or external load-balancer timeout.
  3. NGINX connect, read, and send timeouts.
  4. Any internal proxy or service-mesh timeout.
  5. Application-server request timeout.
  6. Database and other dependency timeouts.

The effective ceiling is imposed by the earliest component that gives up. Align values with the application’s expected behavior and leave enough margin for retries and error handling. Increasing one NGINX directive while an upstream load balancer still stops the request earlier only changes where the error appears.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When—and when not—to change proxy_read_timeout

The NGINX proxy module documents a default proxy_read_timeout of 60 seconds. The directive controls the interval between two successive reads from the proxied server, not the time allowed to transmit the entire response. NGINX’s directive reference states: “The timeout is set only between two successive read operations, not for the transmission of the whole response.”

Increase it only when all of the following are true:

  • The upstream is reachable and healthy.
  • The endpoint is intentionally silent for longer than the current interval.
  • The longer wait fits within every outer proxy, client, and application timeout.
  • Traffic volume and worker capacity can tolerate connections remaining open longer.
  • You have a plan to observe and roll back the change.

Set the directive in the narrowest applicable location so that a long-running report or stream does not make every endpoint wait longer:

location /reports/ {
    proxy_pass http://reports_backend;
    proxy_read_timeout 180s;
}

The syntax and placement must match your active configuration. Validate before reloading:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nginx -t
sudo systemctl reload nginx

Do not use a larger value to mask an unreachable backend, a deadlocked application, a saturated database, or a broken network path. Longer waits consume connections and workers, can increase queueing, and may turn a quick, visible failure into a slower resource-exhaustion incident.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the upstream application and its dependencies

Application capacity

Look for worker saturation, full request queues, CPU throttling, memory pressure, restarts, and pauses caused by garbage collection or runtime initialization. A backend that accepts TCP connections but cannot schedule request work commonly produces a header wait rather than a connect failure.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【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.

Database and storage

Correlate the request timestamp with slow-query logs, connection-pool usage, lock waits, transaction duration, storage latency, and error rates. A single blocked query can hold an application worker long enough for NGINX to time out even while the database remains reachable.

Downstream services

Trace calls made by the upstream to other services, DNS, object storage, queues, or external APIs. Compare their own timeout settings with the NGINX budget. A backend that waits 90 seconds for a dependency cannot reliably satisfy a 60-second proxy read interval.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Streaming and long-running endpoints

For streaming responses, document the expected heartbeat or chunk cadence. If the application intentionally emits no bytes for longer than the read interval, either emit keep-alive data or set a location-specific timeout that remains compatible with the rest of the path.

Escalate temporarily with debug logging

Use debug logging only after ordinary error and access logs, direct testing, and application metrics fail to identify the phase. First confirm that the running binary supports it:

nginx -V 2>&1 | grep -- --with-debug

If the output includes --with-debug, configure an appropriately scoped error log at debug level, reproduce one or a few requests, and capture the resulting lines. Keep the scope and collection window as small as practical. Debug logs can slow operation and consume disk quickly, so monitor disk space and revert to the previous level immediately after collecting evidence.

If the binary does not include debug support, do not assume that installing a different package during an incident is harmless. Continue with timing fields, error logs, direct upstream tests, and application instrumentation, or schedule a controlled package change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify the fix without creating a second outage

  1. Re-run the original request with the same host, method, headers, body, and authentication context.
  2. Confirm that the response status and client-visible behavior are correct, not merely that the 504 disappeared.
  3. Compare upstream_connect_time, upstream_header_time, upstream_response_time, and request_time with the failing sample.
  4. Check that the corresponding timeout message no longer appears in the error log.
  5. Watch application worker, database, connection-pool, CPU, memory, and queue metrics during normal traffic.
  6. Test an intentionally slow or streaming case if that was the reason for a timeout change.
  7. Document the changed directive, scope, previous value, new value, reason, and rollback command.

A successful test request does not prove the incident is resolved if the original problem was load-dependent. Continue observing long enough to cover the traffic pattern that produced the 504.

Common misdiagnoses and safer alternatives

Misdiagnosis Why it is unsafe Better approach
“Every 504 means the application is down.” The application may be reachable but slow before headers or between body reads. Use the error-log operation and all four upstream timing fields.
“Set every timeout to a very large value.” Open connections and workers remain occupied longer, increasing saturation risk. Set a phase-specific, location-specific value only for a proven workload.
“A 60-second failure means the response is limited to 60 seconds.” proxy_read_timeout is an idle interval between reads, not a total-response cap. Measure response cadence and identify the actual silent gap.
“The public URL works, so NGINX can reach the backend.” The public path may use different DNS, routing, firewall rules, or an external load balancer. Run the equivalent request from the NGINX network context.
“Debug logging can stay enabled.” It can affect performance and rapidly consume disk. Enable briefly, collect evidence, then restore the prior level.

A compact incident checklist

  • Record timestamp, host, URI, method, status, request ID, and consistency of failure.
  • Read the active NGINX error log and preserve the complete timeout line.
  • Confirm the access log includes connect, header, response, and total request timings.
  • Classify the failure as connect, header wait, or body-read gap.
  • Test the configured upstream directly from the NGINX host with equivalent request data.
  • Check DNS, routing, firewall rules, listener and port, and backend capacity for connect failures.
  • Check workers, locks, databases, and downstream services for header delays.
  • Check response cadence and streaming behavior for body-read gaps.
  • Compare timeout budgets across client, proxies, NGINX, application, and dependencies.
  • Change proxy_read_timeout only for a healthy backend that intentionally stays silent longer.
  • Use debug logging temporarily and revert it after evidence collection.
  • Verify the original request and watch application and database metrics after the change.

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.