{"id":76,"date":"2026-10-21T05:01:59","date_gmt":"2026-10-21T05:01:59","guid":{"rendered":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/"},"modified":"2026-10-21T05:01:59","modified_gmt":"2026-10-21T05:01:59","slug":"502-vs-504-errors-reverse-proxy-troubleshooting","status":"publish","type":"post","link":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/","title":{"rendered":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures"},"content":{"rendered":"<p>A website may display a 502 or 504 error even though its domain, DNS, and front-end web server are working. Both responses usually indicate trouble between a gateway or reverse proxy and an upstream service. Understanding the difference helps you investigate the correct layer instead of repeatedly restarting everything.<\/p>\n<h2>What a 502 Bad Gateway Usually Means<\/h2>\n<p>A 502 Bad Gateway response means the proxy could not obtain a valid response from the upstream server. The backend may be stopped, listening on a different address, refusing connections, closing the connection unexpectedly, or returning data the proxy cannot interpret.<\/p>\n<p>Start by confirming the upstream address and port in the proxy configuration. Then test the backend directly from the proxy host with a local request. Check whether the application service is running and whether a firewall, Unix socket permission, container network, or TLS setting blocks the connection. Our overview of <a href=\"https:\/\/www.tempohosting.co.uk\/blog\/http-status-codes-explained-for-website-owners\/\" target=\"_blank\" rel=\"noopener\">HTTP status codes<\/a> explains where gateway errors fit within the wider 5xx class.<\/p>\n<h2>What a 504 Gateway Timeout Usually Means<\/h2>\n<p>A 504 Gateway Timeout generally means the proxy reached the upstream path but did not receive the required response within the allowed time. The application may be processing a slow database query, waiting for another API, locked on a resource, overloaded, or simply configured with a task that takes longer than the proxy permits.<\/p>\n<p>Do not begin by increasing every timeout. A longer timeout can hide a slow application while tying up workers and connections for longer. Measure how long the request takes when sent directly to the backend, inspect database and application performance, and decide whether the request should be optimized, moved to a background job, or given a carefully chosen exception.<\/p>\n<h2>Read Logs From Both Sides<\/h2>\n<p>The proxy error log often identifies the failed phase: connecting to the upstream, sending the request, reading response headers, or reading the response body. Match the timestamp and request path with the application, PHP-FPM, container, or database logs. Our guide to <a href=\"https:\/\/www.tempohosting.co.uk\/blog\/linux-log-files-website-troubleshooting\/\" target=\"_blank\" rel=\"noopener\">Linux log files for website troubleshooting<\/a> provides a structured way to correlate these events.<\/p>\n<p>Also check system resources. Exhausted workers, memory pressure, a full disk, or connection limits can produce intermittent gateway errors that disappear during a manual test. Record the upstream response time and error rate so you can see whether failures follow traffic peaks or deployments.<\/p>\n<h2>Fix the Cause and Verify the Result<\/h2>\n<p>For a 502, verify the service endpoint, protocol, permissions, certificates, and application process. For a 504, investigate slow or blocked work before changing timeout values. After editing a proxy configuration, validate its syntax, reload it safely, and repeat the exact failing request.<\/p>\n<p>Monitor the public URL from outside the server and alert on both status codes. A simple homepage check may miss errors limited to login, search, checkout, or API routes, so include important transactions where appropriate.<\/p>\n<p>For the exact behaviour of directives such as <code>proxy_connect_timeout<\/code>, <code>proxy_read_timeout<\/code>, and <code>proxy_next_upstream<\/code>, consult the <a href=\"https:\/\/nginx.org\/en\/docs\/http\/ngx_http_proxy_module.html\" target=\"_blank\" rel=\"noopener\">official NGINX proxy module documentation<\/a>. The status code is a useful clue, but the correlated logs and a direct backend test usually reveal the real fault.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understand the difference between 502 and 504 errors, test the upstream service, correlate proxy logs, and fix reverse proxy failures safely.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[36],"tags":[61,60,33,62,34],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-web-hosting","tag-502-bad-gateway","tag-504-gateway-timeout","tag-http-status-codes","tag-reverse-proxy","tag-server-errors"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog<\/title>\n<meta name=\"description\" content=\"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog\" \/>\n<meta property=\"og:description\" content=\"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/\" \/>\n<meta property=\"og:site_name\" content=\"Tempo Hosting Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-21T05:01:59+00:00\" \/>\n<meta name=\"author\" content=\"Arthur Edward\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Arthur Edward\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/\"},\"author\":{\"name\":\"Arthur Edward\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/#\\\/schema\\\/person\\\/0c5cdd8616ac5c6b1d288da7ec3dd903\"},\"headline\":\"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures\",\"datePublished\":\"2026-10-21T05:01:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/\"},\"wordCount\":505,\"commentCount\":0,\"keywords\":[\"502 Bad Gateway\",\"504 Gateway Timeout\",\"HTTP status codes\",\"reverse proxy\",\"server errors\"],\"articleSection\":[\"Web Hosting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/\",\"url\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/\",\"name\":\"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/#website\"},\"datePublished\":\"2026-10-21T05:01:59+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/#\\\/schema\\\/person\\\/0c5cdd8616ac5c6b1d288da7ec3dd903\"},\"description\":\"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/502-vs-504-errors-reverse-proxy-troubleshooting\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/\",\"name\":\"Tempo Hosting Blog\",\"description\":\"Practical guides to web hosting, websites, domains and online success.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/#\\\/schema\\\/person\\\/0c5cdd8616ac5c6b1d288da7ec3dd903\",\"name\":\"Arthur Edward\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g\",\"caption\":\"Arthur Edward\"},\"url\":\"https:\\\/\\\/www.tempohosting.co.uk\\\/blog\\\/author\\\/arthur-edward\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog","description":"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/","og_locale":"en_US","og_type":"article","og_title":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog","og_description":"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.","og_url":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/","og_site_name":"Tempo Hosting Blog","article_published_time":"2026-10-21T05:01:59+00:00","author":"Arthur Edward","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Arthur Edward","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/#article","isPartOf":{"@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/"},"author":{"name":"Arthur Edward","@id":"https:\/\/www.tempohosting.co.uk\/blog\/#\/schema\/person\/0c5cdd8616ac5c6b1d288da7ec3dd903"},"headline":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures","datePublished":"2026-10-21T05:01:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/"},"wordCount":505,"commentCount":0,"keywords":["502 Bad Gateway","504 Gateway Timeout","HTTP status codes","reverse proxy","server errors"],"articleSection":["Web Hosting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/","url":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/","name":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures - Tempo Hosting Blog","isPartOf":{"@id":"https:\/\/www.tempohosting.co.uk\/blog\/#website"},"datePublished":"2026-10-21T05:01:59+00:00","author":{"@id":"https:\/\/www.tempohosting.co.uk\/blog\/#\/schema\/person\/0c5cdd8616ac5c6b1d288da7ec3dd903"},"description":"Understand 502 vs 504 errors, test the upstream service, read proxy logs, and fix reverse proxy failures without hiding the underlying cause.","breadcrumb":{"@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.tempohosting.co.uk\/blog\/502-vs-504-errors-reverse-proxy-troubleshooting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.tempohosting.co.uk\/blog\/"},{"@type":"ListItem","position":2,"name":"502 vs 504 Errors: How to Troubleshoot Reverse Proxy Failures"}]},{"@type":"WebSite","@id":"https:\/\/www.tempohosting.co.uk\/blog\/#website","url":"https:\/\/www.tempohosting.co.uk\/blog\/","name":"Tempo Hosting Blog","description":"Practical guides to web hosting, websites, domains and online success.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tempohosting.co.uk\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.tempohosting.co.uk\/blog\/#\/schema\/person\/0c5cdd8616ac5c6b1d288da7ec3dd903","name":"Arthur Edward","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d305c187f77f40bd7f15259964168e8350a52598793dbb6c5ee98b63e767dada?s=96&d=mm&r=g","caption":"Arthur Edward"},"url":"https:\/\/www.tempohosting.co.uk\/blog\/author\/arthur-edward\/"}]}},"_links":{"self":[{"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":0,"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tempohosting.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}