{"id":5033,"date":"2026-11-01T10:52:40","date_gmt":"2026-11-01T10:52:40","guid":{"rendered":"https:\/\/zynoo.com\/blog\/?p=5033"},"modified":"2026-11-01T15:40:38","modified_gmt":"2026-11-01T15:40:38","slug":"502-bad-gateway-nginx","status":"publish","type":"post","link":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/","title":{"rendered":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\" id=\"h-\">A <strong>502 Bad Gateway error in Nginx<\/strong> usually means Nginx couldn&#8217;t receive a valid response from an upstream server, such as PHP-FPM, Node.js, or another backend application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The most common causes are stopped application services, incorrect upstream ports or sockets, and backend processes that crash or close connections unexpectedly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Start by checking your Nginx error logs.<\/strong> They often reveal exactly why the connection failed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide walks through seven practical troubleshooting steps for Linux servers running Nginx.<\/p>\n\n\n\n<h2 id=\"h-what-causes-a-502-bad-gateway-error-in-nginx\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_Causes_a_502_Bad_Gateway_Error_in_Nginx\"><\/span>What Causes a 502 Bad Gateway Error in Nginx?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx frequently acts as a reverse proxy, forwarding requests to backend applications and returning their responses to visitors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the upstream service fails to respond correctly, Nginx may return HTTP status code 502.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common causes include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Backend services that have stopped or crashed.<\/li>\n\n\n\n<li>Incorrect upstream IP addresses, ports, or Unix sockets.<\/li>\n\n\n\n<li>PHP-FPM or application process failures.<\/li>\n\n\n\n<li>Socket access permission problems.<\/li>\n\n\n\n<li>Insufficient memory or disk space.<\/li>\n\n\n\n<li>Invalid or prematurely closed upstream connections.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The following checks assume you have SSH access and permission to administer your Linux server.<\/p>\n\n\n\n<div class=\"wp-block-group zynoo-related-reading has-border-color has-text-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"border-color:#c7d8ef;border-width:1px;border-radius:8px;border-left-color:#0069ff;border-left-width:3px;color:#24364f;background-color:#eaf2ff;margin-top:28px;margin-bottom:28px;padding-top:18px;padding-right:22px;padding-bottom:18px;padding-left:22px;font-size:16px;line-height:1.8\">\n<p class=\"wp-block-paragraph\"><strong>If you&#8217;re unfamiliar with accessing a remote server,<\/strong> read our <a href=\"https:\/\/zynoo.com\/blog\/ssh-commands\/\">SSH commands beginner&#8217;s guide<\/a> before continuing.<\/p>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx-1024x576.webp\" alt=\"what cause 502 Bad Gateway Nginx\" class=\"wp-image-5037\" srcset=\"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx-1024x576.webp 1024w, https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx-300x169.webp 300w, https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx-768x432.webp 768w, https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx-1536x864.webp 1536w, https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/what-cause-502-Bad-Gateway-Nginx.webp 1672w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 id=\"h-1-check-the-nginx-error-logs\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Check_the_Nginx_Error_Logs\"><\/span>1. Check the Nginx Error Logs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx error logs are usually the fastest way to identify a 502 problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your server through SSH and run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tail -n 50 \/var\/log\/nginx\/error.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays the latest 50 log entries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For live troubleshooting, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tail -f \/var\/log\/nginx\/error.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Reload the affected webpage and watch for new messages.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Log message<\/th><th>Likely problem<\/th><\/tr><tr><td><code>connect() failed (111: Connection refused)<\/code><\/td><td>Backend isn&#8217;t accepting connections<\/td><\/tr><tr><td><code>No such file or directory<\/code><\/td><td>Configured upstream socket is missing<\/td><\/tr><tr><td><code>Permission denied<\/code><\/td><td>Nginx cannot access the socket or resource<\/td><\/tr><tr><td><code>upstream prematurely closed connection<\/code><\/td><td>Backend closed the connection unexpectedly<\/td><\/tr><tr><td><code>upstream sent invalid header<\/code><\/td><td>Backend returned malformed response headers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Your hosting configuration may use a different log location.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Don&#8217;t change Nginx settings until you&#8217;ve identified the likely cause.<\/strong><\/p>\n\n\n\n<h2 id=\"h-2-check-whether-the-backend-service-is-running\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Check_Whether_the_Backend_Service_Is_Running\"><\/span>2. Check Whether the Backend Service Is Running<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A 502 error often occurs because the application behind Nginx has stopped.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a systemd-managed application service, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status myapp<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>myapp<\/code> with your actual service name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For PHP-based applications using PHP-FPM, the service might look like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status php8.3-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The installed PHP version and service name may differ.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the service has failed, inspect its logs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo journalctl -u myapp -n 50<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check for crashes, missing dependencies, configuration errors, or memory-related failures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Restart the service only after identifying and addressing the underlying problem.<\/p>\n\n\n\n<h2 id=\"h-3-verify-the-upstream-port-or-socket\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Verify_the_Upstream_Port_or_Socket\"><\/span>3. Verify the Upstream Port or Socket<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx must forward requests to the correct backend address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, a reverse proxy might contain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location \/ {\n    proxy_pass http:\/\/127.0.0.1:3000;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This tells Nginx to forward requests to an HTTP application listening on port 3000.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether something is listening there:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ss -ltnp | grep ':3000'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also test an HTTP backend directly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -i http:\/\/127.0.0.1:3000\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the backend isn&#8217;t available, investigate its service configuration before changing Nginx.<\/p>\n\n\n\n<h3 id=\"h-check-php-fpm-sockets\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Check_PHP-FPM_Sockets\"><\/span>Check PHP-FPM Sockets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PHP-FPM commonly uses Unix sockets or TCP ports.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An Nginx configuration might contain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fastcgi_pass unix:\/run\/php\/php8.3-fpm.sock;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether the configured socket exists:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/run\/php\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The socket path must match the PHP-FPM pool&#8217;s <code>listen<\/code> setting, and Nginx must have permission to connect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> <code>proxy_pass<\/code> is used for HTTP upstreams, while <code>fastcgi_pass<\/code> is used for <a href=\"https:\/\/en.wikipedia.org\/wiki\/FastCGI\">FastCGI<\/a> services such as PHP-FPM. They aren&#8217;t interchangeable.<\/p>\n\n\n\n<div class=\"wp-block-group zynoo-related-reading has-border-color has-text-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"border-color:#c7d8ef;border-width:1px;border-radius:8px;border-left-color:#0069ff;border-left-width:3px;color:#24364f;background-color:#eaf2ff;margin-top:28px;margin-bottom:28px;padding-top:18px;padding-right:22px;padding-bottom:18px;padding-left:22px;font-size:16px;line-height:1.8\">\n<p class=\"wp-block-paragraph\"><strong>If you&#8217;re configuring Nginx for the first time, make sure proxy_pass points to the correct backend address.<\/strong> Our <a href=\"https:\/\/zynoo.com\/blog\/nginx-reverse-proxy-ubuntu\/\">Nginx reverse proxy tutorial for Ubuntu<\/a> shows how to set up request forwarding, test the configuration, and enable HTTPS.<\/p>\n<\/div>\n\n\n\n<h2 id=\"h-4-check-server-memory-and-disk-space\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Check_Server_Memory_and_Disk_Space\"><\/span>4. Check Server Memory and Disk Space<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Backend applications may crash or stop responding when the server runs out of resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check memory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>free -h<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check disk space:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df -h<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check running processes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>top<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If an application was terminated because of memory pressure, you may find relevant messages in the system journal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo journalctl -k --since \"1 hour ago\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Look for out-of-memory events or process termination messages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If disk space is exhausted, identify what&#8217;s consuming it before deleting files.<\/p>\n\n\n\n<div class=\"wp-block-group zynoo-related-reading has-border-color has-text-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"border-color:#c7d8ef;border-width:1px;border-radius:8px;border-left-color:#0069ff;border-left-width:3px;color:#24364f;background-color:#eaf2ff;margin-top:28px;margin-bottom:28px;padding-top:18px;padding-right:22px;padding-bottom:18px;padding-left:22px;font-size:16px;line-height:1.8\">\n<p class=\"wp-block-paragraph\"><strong>For additional monitoring commands,<\/strong> see our <a href=\"https:\/\/zynoo.com\/blog\/linux-commands-for-server-management\/\">essential Linux commands for server management<\/a>.<\/p>\n<\/div>\n\n\n\n<h2 id=\"h-5-check-socket-permissions-and-application-logs\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Check_Socket_Permissions_and_Application_Logs\"><\/span>5. Check Socket Permissions and Application Logs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes the backend is running, but Nginx cannot communicate with it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Unix sockets, inspect ownership and permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/run\/php\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Also check the directories leading to the socket if the logs report a permission error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The correct permissions depend on the Nginx worker user and backend service configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Avoid applying broad permissions such as <code>chmod 777<\/code>. Instead, adjust the relevant service or pool configuration so authorized processes can access the socket.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the error logs report that the upstream closed its connection prematurely, inspect the backend application&#8217;s logs for crashes, exceptions, or failed requests.<\/p>\n\n\n\n<h2 id=\"h-6-test-your-nginx-configuration\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Test_Your_Nginx_Configuration\"><\/span>6. Test Your Nginx Configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Incorrect proxy settings or configuration changes can also disrupt upstream communication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before applying changes, validate the Nginx configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nginx -t<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the test succeeds, reload Nginx:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl reload nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Reloading applies valid configuration changes without unnecessarily restarting the service.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the test fails, correct the reported configuration error first.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t increase proxy timeouts or buffer limits blindly. These adjustments won&#8217;t fix a stopped backend, incorrect socket, or connection refusal.<\/p>\n\n\n\n<h2 id=\"h-7-confirm-that-the-502-error-is-fixed\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Confirm_That_the_502_Error_Is_Fixed\"><\/span>7. Confirm That the 502 Error Is Fixed<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After addressing the underlying issue, test the affected URL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -I https:\/\/example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>example.com<\/code> with your actual domain.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A successful request typically returns an appropriate HTTP status such as <code>200 OK<\/code>, although redirects and other valid responses may produce different codes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also open the website in your browser and review the Nginx error logs again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the error returns under load, monitor the backend service and resource usage while reproducing the problem.<\/p>\n\n\n\n<h2 id=\"h-how-to-prevent-nginx-502-errors\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Prevent_Nginx_502_Errors\"><\/span>How to Prevent Nginx 502 Errors<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Not every backend failure is preventable, but good server administration reduces avoidable outages.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Monitor Nginx and backend service health.<\/li>\n\n\n\n<li>Review application logs after deployments.<\/li>\n\n\n\n<li>Configure appropriate service recovery policies.<\/li>\n\n\n\n<li>Monitor memory, storage, and connection usage.<\/li>\n\n\n\n<li>Validate configuration changes before applying them.<\/li>\n\n\n\n<li>Test applications directly before routing traffic through Nginx.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If an application requires more resources, measure its actual usage before deciding to upgrade server capacity.<\/p>\n\n\n\n<div class=\"wp-block-group zynoo-related-reading has-border-color has-text-color has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"border-color:#c7d8ef;border-width:1px;border-radius:8px;border-left-color:#0069ff;border-left-width:3px;color:#24364f;background-color:#eaf2ff;margin-top:28px;margin-bottom:28px;padding-top:18px;padding-right:22px;padding-bottom:18px;padding-left:22px;font-size:16px;line-height:1.8\">\n<p class=\"wp-block-paragraph\">A 502 error indicates an invalid upstream response, while a <strong>504 error<\/strong> occurs when the upstream server takes too long to respond. If you&#8217;re experiencing the latter, follow our guide to fix the <a href=\"https:\/\/zynoo.com\/blog\/504-gateway-timeout\/\">504 Gateway Timeout error<\/a> and troubleshoot slow applications, server resources, and proxy timeout settings.<\/p>\n<\/div>\n\n\n\n<h2 id=\"h-frequently-asked-questions\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span>Frequently Asked Questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1793529208055\"><strong class=\"schema-faq-question\">What does 502 Bad Gateway mean in Nginx?<\/strong> <p class=\"schema-faq-answer\">It means Nginx, acting as a gateway or proxy, received an invalid response from an upstream server. The cause is often a stopped backend service or an upstream connection problem.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793529240063\"><strong class=\"schema-faq-question\">Does restarting Nginx fix a 502 error?<\/strong> <p class=\"schema-faq-answer\">Not necessarily. Restarting or reloading Nginx won&#8217;t fix an unavailable application, incorrect backend port, or missing PHP-FPM socket.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793529252450\"><strong class=\"schema-faq-question\">What&#8217;s the difference between HTTP 502 and HTTP 504?<\/strong> <p class=\"schema-faq-answer\">A 502 error indicates an invalid response from the upstream server, while a 504 error means the gateway didn&#8217;t receive a response from the upstream server within the timeout period.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793529289265\"><strong class=\"schema-faq-question\">Can low RAM cause a 502 Bad Gateway error?<\/strong> <p class=\"schema-faq-answer\">Yes. Memory exhaustion can cause backend processes to crash or be terminated, leaving Nginx unable to communicate with them.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793529308749\"><strong class=\"schema-faq-question\">Is a 502 error always caused by Nginx?<\/strong> <p class=\"schema-faq-answer\">No. Other gateways, proxies, CDNs, and load balancers can also return HTTP 502 errors.<\/p> <\/div> <\/div>\n\n\n\n<h2 id=\"h-conclusion\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Fixing a <strong>502 Bad Gateway error in Nginx<\/strong> starts with identifying why the upstream application isn&#8217;t responding correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check Nginx error logs first, confirm the backend service is running, and verify the configured port or socket. Then investigate resource limits, permissions, and application failures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In most cases, identifying the specific upstream failure is more effective than repeatedly restarting Nginx or changing timeout settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A 502 Bad Gateway error in Nginx usually means Nginx couldn&#8217;t receive a valid response from an upstream server, such as PHP-FPM, Node.js, or another backend application. The most common causes are stopped application services, incorrect upstream ports or sockets, and backend processes that crash or close connections unexpectedly. Start by checking your Nginx error [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":5036,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[499],"tags":[],"class_list":["post-5033","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v28.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Fix 502 Bad Gateway in Nginx (Step-by-Step)<\/title>\n<meta name=\"description\" content=\"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)\" \/>\n<meta property=\"og:description\" content=\"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/\" \/>\n<meta property=\"og:site_name\" content=\"ZYNOO Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-01T10:52:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-01T15:40:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1672\" \/>\n\t<meta property=\"og:image:height\" content=\"941\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Adam Weller\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Adam Weller\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/\"},\"author\":{\"name\":\"Adam Weller\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#\\\/schema\\\/person\\\/dc0f08d1e3da74e3d4ae21a072525738\"},\"headline\":\"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)\",\"datePublished\":\"2026-11-01T10:52:40+00:00\",\"dateModified\":\"2026-11-01T15:40:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/\"},\"wordCount\":1176,\"publisher\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/502-Bad-Gateway-Nginx.webp\",\"articleSection\":[\"Linux Tutorials\"],\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/\",\"name\":\"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/502-Bad-Gateway-Nginx.webp\",\"datePublished\":\"2026-11-01T10:52:40+00:00\",\"dateModified\":\"2026-11-01T15:40:38+00:00\",\"description\":\"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529208055\"},{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529240063\"},{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529252450\"},{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529289265\"},{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529308749\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/502-Bad-Gateway-Nginx.webp\",\"contentUrl\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/502-Bad-Gateway-Nginx.webp\",\"width\":1672,\"height\":941,\"caption\":\"502 Bad Gateway Nginx\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux Tutorials\",\"item\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/category\\\/linux-tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/\",\"name\":\"Zynoo Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#organization\",\"name\":\"ZYNOO\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/logo.png\",\"width\":149,\"height\":31,\"caption\":\"ZYNOO\"},\"image\":{\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/#\\\/schema\\\/person\\\/dc0f08d1e3da74e3d4ae21a072525738\",\"name\":\"Adam Weller\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/adam-weller-v2-96x96.jpg\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/adam-weller-v2-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/adam-weller-v2-96x96.jpg\",\"caption\":\"Adam Weller\"},\"description\":\"Adam Weller covers web hosting, Linux and online projects for the ZYNOO blog.\",\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/author\\\/adam-weller\\\/\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529208055\",\"position\":1,\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529208055\",\"name\":\"What does 502 Bad Gateway mean in Nginx?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It means Nginx, acting as a gateway or proxy, received an invalid response from an upstream server. The cause is often a stopped backend service or an upstream connection problem.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529240063\",\"position\":2,\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529240063\",\"name\":\"Does restarting Nginx fix a 502 error?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Not necessarily. Restarting or reloading Nginx won't fix an unavailable application, incorrect backend port, or missing PHP-FPM socket.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529252450\",\"position\":3,\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529252450\",\"name\":\"What's the difference between HTTP 502 and HTTP 504?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"A 502 error indicates an invalid response from the upstream server, while a 504 error means the gateway didn't receive a response from the upstream server within the timeout period.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529289265\",\"position\":4,\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529289265\",\"name\":\"Can low RAM cause a 502 Bad Gateway error?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. Memory exhaustion can cause backend processes to crash or be terminated, leaving Nginx unable to communicate with them.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529308749\",\"position\":5,\"url\":\"https:\\\/\\\/zynoo.com\\\/blog\\\/502-bad-gateway-nginx\\\/#faq-question-1793529308749\",\"name\":\"Is a 502 error always caused by Nginx?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. Other gateways, proxies, CDNs, and load balancers can also return HTTP 502 errors.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)","description":"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.","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:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/","og_locale":"en_US","og_type":"article","og_title":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)","og_description":"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.","og_url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/","og_site_name":"ZYNOO Blog","article_published_time":"2026-11-01T10:52:40+00:00","article_modified_time":"2026-11-01T15:40:38+00:00","og_image":[{"width":1672,"height":941,"url":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp","type":"image\/webp"}],"author":"Adam Weller","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Adam Weller","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#article","isPartOf":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/"},"author":{"name":"Adam Weller","@id":"https:\/\/zynoo.com\/blog\/#\/schema\/person\/dc0f08d1e3da74e3d4ae21a072525738"},"headline":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)","datePublished":"2026-11-01T10:52:40+00:00","dateModified":"2026-11-01T15:40:38+00:00","mainEntityOfPage":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/"},"wordCount":1176,"publisher":{"@id":"https:\/\/zynoo.com\/blog\/#organization"},"image":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp","articleSection":["Linux Tutorials"],"inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/","url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/","name":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)","isPartOf":{"@id":"https:\/\/zynoo.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#primaryimage"},"image":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp","datePublished":"2026-11-01T10:52:40+00:00","dateModified":"2026-11-01T15:40:38+00:00","description":"Fix 502 Bad Gateway errors in Nginx by checking logs, upstreams, PHP-FPM, proxy settings, and server resources with Linux commands.","breadcrumb":{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529208055"},{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529240063"},{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529252450"},{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529289265"},{"@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529308749"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#primaryimage","url":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp","contentUrl":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/502-Bad-Gateway-Nginx.webp","width":1672,"height":941,"caption":"502 Bad Gateway Nginx"},{"@type":"BreadcrumbList","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zynoo.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Linux Tutorials","item":"https:\/\/zynoo.com\/blog\/category\/linux-tutorials\/"},{"@type":"ListItem","position":3,"name":"How to Fix 502 Bad Gateway in Nginx (Step-by-Step)"}]},{"@type":"WebSite","@id":"https:\/\/zynoo.com\/blog\/#website","url":"https:\/\/zynoo.com\/blog\/","name":"Zynoo Blog","description":"","publisher":{"@id":"https:\/\/zynoo.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/zynoo.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/zynoo.com\/blog\/#organization","name":"ZYNOO","url":"https:\/\/zynoo.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zynoo.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2025\/08\/logo.png","contentUrl":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2025\/08\/logo.png","width":149,"height":31,"caption":"ZYNOO"},"image":{"@id":"https:\/\/zynoo.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/zynoo.com\/blog\/#\/schema\/person\/dc0f08d1e3da74e3d4ae21a072525738","name":"Adam Weller","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/adam-weller-v2-96x96.jpg","url":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/adam-weller-v2-96x96.jpg","contentUrl":"https:\/\/zynoo.com\/blog\/wp-content\/uploads\/2026\/11\/adam-weller-v2-96x96.jpg","caption":"Adam Weller"},"description":"Adam Weller covers web hosting, Linux and online projects for the ZYNOO blog.","url":"https:\/\/zynoo.com\/blog\/author\/adam-weller\/"},{"@type":"Question","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529208055","position":1,"url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529208055","name":"What does 502 Bad Gateway mean in Nginx?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It means Nginx, acting as a gateway or proxy, received an invalid response from an upstream server. The cause is often a stopped backend service or an upstream connection problem.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529240063","position":2,"url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529240063","name":"Does restarting Nginx fix a 502 error?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Not necessarily. Restarting or reloading Nginx won't fix an unavailable application, incorrect backend port, or missing PHP-FPM socket.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529252450","position":3,"url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529252450","name":"What's the difference between HTTP 502 and HTTP 504?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"A 502 error indicates an invalid response from the upstream server, while a 504 error means the gateway didn't receive a response from the upstream server within the timeout period.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529289265","position":4,"url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529289265","name":"Can low RAM cause a 502 Bad Gateway error?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes. Memory exhaustion can cause backend processes to crash or be terminated, leaving Nginx unable to communicate with them.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529308749","position":5,"url":"https:\/\/zynoo.com\/blog\/502-bad-gateway-nginx\/#faq-question-1793529308749","name":"Is a 502 error always caused by Nginx?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"No. Other gateways, proxies, CDNs, and load balancers can also return HTTP 502 errors.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/posts\/5033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/comments?post=5033"}],"version-history":[{"count":6,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/posts\/5033\/revisions"}],"predecessor-version":[{"id":5239,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/posts\/5033\/revisions\/5239"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/media\/5036"}],"wp:attachment":[{"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/media?parent=5033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/categories?post=5033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zynoo.com\/blog\/wp-json\/wp\/v2\/tags?post=5033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}