{"id":1462,"date":"2011-10-30T09:16:23","date_gmt":"2011-10-30T13:16:23","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=1462"},"modified":"2013-03-20T08:44:20","modified_gmt":"2013-03-20T12:44:20","slug":"nginx-502-bad-gateway-error","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/nginx-502-bad-gateway-error","title":{"rendered":"Nginx 502 Bad Gateway error"},"content":{"rendered":"<p>My server went down today and after restarting, it came up with a<strong> &#8220;Nginx 502 Bad Gateway&#8221; message.<\/strong> At first I thought its something related to the Nginx service, so restarted the nginx service but immediately realized it wasn&#8217;t the case.<\/p>\n<p>Nginx receives a request on port 80 and it then proxies the request to &#8216;localhost&#8217; on port 8080 (in my case) where another service is configured on it.<strong> If no service is listening on port 8080, it results in a &#8216;Nginx 502 Bad gateway&#8217; message.<\/strong> I immediately realized it was the Java service binded on port 8080 of my server and started it.<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># java -jar \/home\/user\/test.jar<\/span><\/pre>\n<\/blockquote>\n<p>The website was online immediately.<\/p>\n<p>The Nginx proxy port is defined in the Nginx configuration file and different services could be binded to the proxy port depending on your setup. It could be<\/p>\n<p><strong>1)<\/strong> PHP-fpm<br \/>\n<strong>2)<\/strong> php_cgi<br \/>\n<strong>3)<\/strong> FastCGI<\/p>\n<p>OR could be something else. <strong>You have to start the service listening on the proxy port to get your website\/application online.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>My server went down today and after restarting, it came up with a &#8220;Nginx 502 Bad Gateway&#8221; message. At first I thought its something related to the Nginx service, so restarted the nginx service but immediately realized it wasn&#8217;t the case.<br \/>\nNginx receives a request on port 80 and it then proxies the request to &#8216;localhost&#8217; on port 8080 (in my case) where another service is configured on it. If no service is listening on port 8080, it results in a &#8216;Nginx 502 Bad gateway&#8217; message. I immediately realized [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[1308,1313,1314,1312,1311,1310,1315,1309],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1462"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=1462"}],"version-history":[{"count":6,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1462\/revisions"}],"predecessor-version":[{"id":2284,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1462\/revisions\/2284"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=1462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=1462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=1462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}