{"id":1494,"date":"2021-08-15T12:30:30","date_gmt":"2021-08-15T17:30:30","guid":{"rendered":"https:\/\/linuxhostsupport.com\/blog\/?p=1494"},"modified":"2021-07-14T02:05:54","modified_gmt":"2021-07-14T07:05:54","slug":"how-to-fix-502-bad-gateway-error-in-nginx","status":"publish","type":"post","link":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/","title":{"rendered":"How To Fix \u201c502 Bad Gateway\u201d Error In Nginx"},"content":{"rendered":"\r\n<div id=\"linux-3072797974\" class=\"linux-before-1st-paragraph linux-entity-placement\" style=\"margin-top: 15px;margin-bottom: 15px;\"><a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting\/?mtm_campaign=blogs&#038;mtm_source=lhs&#038;mtm_medium=blog&#038;mtm_content=managed-vps&#038;mtm_cid=1339&#038;mtm_placement=inline\" aria-label=\"Untitled\"><img src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322.jpg\" alt=\"\"  srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322.jpg 728w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340090_NVMeGoogleAds_728x90_041322-300x37.jpg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" width=\"728\" height=\"90\"  style=\"display: inline-block;\" \/><\/a><\/div><p>The 502 Bad Gateway error is an HTTP status code that means that one server received an invalid response from another server. In more technical words, A 502 Bad Gateway means that the proxy (gateway) server wasn\u2019t able to get a valid or any response from the upstream server.<\/p>\r\n<p><img decoding=\"async\" class=\"alignright  wp-image-1498\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/fixing-502-bad-gateway-error-in-nginx.png\" alt=\"fixing 502 bad gateway error in nginx\" width=\"141\" height=\"163\" \/><\/p>\r\n\r\n\r\n\r\n<p>If you are seeing a 502 bad gateway error on a website, it means that the origin server sent out an invalid response to another server that acted as a gateway or proxy. It can be a tricky investigation to locate what and where is the process which caused the issue. However, there are some general troubleshooting steps that you can follow to get it solved.<\/p>\r\n\r\n\r\n\r\n<p>For example, if you use Nginx as the webserver and you encounter this issue, it could be that Nginx is unable to communicate with the upstream server, this upstream server could be PHP-FPM or other application that you want to access through Nginx, like Odoo, NodeJS, etc.<!--more--><\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-how-to-fix-502-gateway-error-in-nginx\">How to Fix 502 Gateway Error in Nginx<\/h2>\r\n\r\n\r\n\r\n<p>First, you need to investigate your Nginx server block and check what the upstream server is.<\/p>\r\n\r\n\r\n\r\n<p>For example, we have a WordPress website at blog.yourdomain.com, and this is the Nginx server block configuration.<\/p>\r\n<p><img decoding=\"async\" class=\"aligncenter wp-image-1500 size-full\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-repair-502-bad-gateway-error-in-nginx.png\" alt=\"how to repair 502 bad gateway error in nginx\" width=\"704\" height=\"448\" srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-repair-502-bad-gateway-error-in-nginx.png 704w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-repair-502-bad-gateway-error-in-nginx-300x191.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/p>\r\n\r\n\r\n\r\n\r\n\r\n<p>According to the configuration, as shown in the picture above, the website&#8217;s PHP files are processed by fastcgi running on port 9000.<\/p>\r\n\r\n\r\n\r\n<p>To check what is running on port 9000, we can issue this shell command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo netstat -pltn | grep 9000<\/code><\/pre>\r\n\r\n\r\n\r\n<p>or<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo lsof -i :9000<\/code><\/pre>\r\n\r\n\r\n\r\n<p>If a process is running on port 9000, you should see something like this after invoking the shell command.<\/p>\r\n<p><img decoding=\"async\" class=\"aligncenter wp-image-1501 size-full\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/repairing-502-bad-gateway-error-in-nginx.png\" alt=\"repairing 502 bad gateway error in nginx\" width=\"829\" height=\"131\" srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/repairing-502-bad-gateway-error-in-nginx.png 829w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/repairing-502-bad-gateway-error-in-nginx-300x47.png 300w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/repairing-502-bad-gateway-error-in-nginx-768x121.png 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/p>\r\n\r\n\r\n\r\n\r\n\r\n<p>If the shell command does not print anything on the screen, then the process is dead. This is why you see the 502 bad gateway error when accessing your WordPress website.<\/p>\r\n\r\n\r\n\r\n<p>The next step is to find what pservice should run on port 9000, you can run this command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo grep -rl 9000 \/etc<\/code><\/pre>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"size-full wp-image-1502 aligncenter\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/removing-502-bad-gateway-error-in-nginx.png\" alt=\"removing 502 bad gateway error in nginx\" width=\"816\" height=\"131\" srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/removing-502-bad-gateway-error-in-nginx.png 816w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/removing-502-bad-gateway-error-in-nginx-300x48.png 300w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/removing-502-bad-gateway-error-in-nginx-768x123.png 768w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>As we can see in the picture, it seems that php-fpm7.2 should run to process the PHP files.<\/p>\r\n\r\n\r\n\r\n<p>In the latest CentOS and Ubuntu, you can invoke this command to see where the process should be run from:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl list-unit-files | grep fpm<\/code><\/pre>\r\n\r\n\r\n\r\n<p>or<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl -l | grep -i fpm<\/code><\/pre>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1503\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-remove-502-bad-gateway-error-in-nginx.png\" alt=\"how to remove 502 bad gateway error in nginx\" width=\"1024\" height=\"98\" srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-remove-502-bad-gateway-error-in-nginx.png 1024w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-remove-502-bad-gateway-error-in-nginx-300x29.png 300w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-remove-502-bad-gateway-error-in-nginx-768x74.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>If the process is stopped, this is most likely because your server has run out of memory, although you can try to restart it by running this command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start php7.2-fpm<\/code><\/pre>\r\n\r\n\r\n\r\n<p>But, if you see that php-fpm process is running, it means php-fpm could not respond in time and Nginx is unable to communicate with it, hence the issue.<\/p>\r\n\r\n\r\n\r\n<p>To solve this php-fpm issue, we can tweak Nginx and PHP-FPM configurations.<\/p>\r\n\r\n\r\n\r\n<p>Increase the timeouts and buffers between NGINX and PHP-FPM.<\/p>\r\n\r\n\r\n\r\n<p>Increasing the buffers and timeouts gives NGINX \/ PHP-FPM space to work, particularly if you have any heavy PHP scripts. In the HTTP or location block of your NGINX site configuration, add the following to increase buffers and timeouts:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>location {\r\n\u2026\r\n   fastcgi_buffers 8 16k;\r\n   fastcgi_buffer_size 32k;\r\n   fastcgi_connect_timeout 60;\r\n   fastcgi_send_timeout 300;\r\n   fastcgi_read_timeout 300;\r\n}<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-change-php-fpm-configuration\">Change PHP-FPM configuration<\/h2>\r\n\r\n\r\n\r\n<p>PHP-FPM can be configured to listen on a file or tcp\/ip as a socket. If you configure php-fpm to listen on tcp\/ip as a socket, you would want to switch to a file because theoretically the file saved on a disk could be accessed faster.<\/p>\r\n\r\n\r\n\r\n<p>To do this, in your PHP-FPM configuration file, you need to change the following: <code>listen = 127.0.0.1:9000<\/code><\/p>\r\n\r\n\r\n\r\n<p>to this: <code>listen = \/var\/run\/php7.2-fpm.sock<\/code><\/p>\r\n\r\n\r\n\r\n<p>You can choose whatever the socket name is, just remember and make sure your Nginx is configured to connect to the socket file<\/p>\r\n\r\n\r\n\r\n<p>After making the changes, you need to adjust your Nginx server block as well. In your Nginx server block, change this line<\/p>\r\n\r\n\r\n\r\n<p><code>fastcgi_pass 127.0.0.1:9000;<\/code> to <code>fastcgi_pass unix:\/var\/run\/php7.2-fpm.sock;<\/code><\/p>\r\n\r\n\r\n\r\n<p>Then, check your Nginx configuration with <code>nginx -t<\/code> and reload both Nginx and php-fpm services.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl reload nginx\r\n$ sudo systemctl reload php7.2-fpm<\/code><\/pre>\r\n\r\n\r\n\r\n<p>If the PHP-FPM processes are running but you are seeing the 502 error message, then you would need to tine tune your PHP-FPM\u2019s process management to utilize the available memory on the server properly.<\/p>\r\n\r\n\r\n\r\n<p>There are three process manager options you can choose from.<\/p>\r\n\r\n\r\n\r\n<p><em>static <\/em>&#8211; a fixed number of child processes, i.e the value of pm.max_children <em>dynamic <\/em>&#8211; the number of child processes are set dynamically <em>ondemand <\/em>&#8211; children will be forked when new requests will connect<\/p>\r\n\r\n\r\n\r\n<p>By default, the dynamic process manager is activated, if you use this process manager and see a similar message below in the PHP-FPM log:<\/p>\r\n\r\n\r\n\r\n<p><code><em>WARNING: [pool nnnnn] seems busy (you may need to increase pm.start_servers, or pm.min\/max_spare_servers), spawning 64 children, there are 8 idle, and 79 total children<\/em><\/code><\/p>\r\n\r\n\r\n\r\n<p>then this can trigger the 502 error message on your site, you need to adjust the pm.start_servers, or pm.min\/max_spare_servers values to get this fixed. Or, use &#8216;ondemand&#8217; instead of &#8216;dynamic&#8217;. The &#8216;ondemand&#8217; will be more efficient, although you need to calculate them based on your server&#8217;s amount of RAM, how much a PHP-FPM process consumes memory, etc.<\/p>\r\n\r\n\r\n\r\n<p>With &#8216;static&#8217; as the process manager, you will keep everything sitting in memory, traffic spikes will only cause fewer spikes to your CPU, this will make your CPU average lower, but RAM usage may be higher.<\/p>\r\n\r\n\r\n\r\n<p>If your website is using another application and connected to Nginx as the reverse proxy and you see the 502 error message, most likely the application behind Nginx is down.<\/p>\r\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-1504\" src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/fix-nginx-502-bad-gateway-error.png\" alt=\"fix nginx 502 bad gateway error\" width=\"998\" height=\"529\" srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/fix-nginx-502-bad-gateway-error.png 998w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/fix-nginx-502-bad-gateway-error-300x159.png 300w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/fix-nginx-502-bad-gateway-error-768x407.png 768w\" sizes=\"(max-width: 998px) 100vw, 998px\" \/><\/p>\r\n\r\n\r\n\r\n\r\n\r\n<p>The picture above tells us that Nginx is connected to an Odoo instance on port 8069. We can check whether Odoo is running or not, by running the <em>netstat <\/em>command as mentioned earlier in this blogpost.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo netstat -pltn | grep 8069<\/code><\/pre>\r\n\r\n\r\n\r\n<p>or<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo lsof -i :8069<\/code><\/pre>\r\n\r\n\r\n\r\n<p>If none of the above commands print anything, then it means Odoo is down. You need to check the service name and then start it.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl -l | grep -i odoo<\/code><\/pre>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start odoo<\/code><\/pre>\r\n\r\n\r\n\r\n<p>To further investigate why Odoo or PHP-FPM is down, we can run this command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>$ sudo dmesg -T | egrep -i 'killed process'<\/code><\/pre>\r\n\r\n\r\n\r\n<p>It might print something like this:<\/p>\r\n\r\n\r\n\r\n<p><em><code>[Tue Jul 13 22:59:47 2021] Out of memory in UB 1644: OOM killed process 27128 (phyton3) score 0 vm:6107440kB, rss:113576kB, swap:0kB<\/code><\/em><\/p>\r\n\r\n\r\n\r\n<p>It means your server is running out of memory, you would need to tweak your Odoo configuration. You can check one of our Odoo related posts at <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-speed-up-odoo\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Speed up Odoo &#8211; RoseHosting<\/a> or contact our support team if you have a server with us.<\/p>\r\n\r\n\r\n<hr class=\"wp-block-separator\" \/>\r\n\r\n\r\n<p>Of course, you don\u2019t need to get troubled with your server if you have a <a href=\"https:\/\/www.rosehosting.com\/linux-vps-hosting\/\" target=\"_blank\" rel=\"noopener\">managed VPS hosting<\/a> with us \u2013 in which case, our technical support team will help you investigate and solve this 502 Bad Gateway issue immediately. They are available 24\/7 and can cater to any questions or requests.<\/p>\r\n\r\n\r\n\r\n<p>PS. If you liked this post, feel free to share it with your friends by using the social media share shortcuts below, or simply leave a comment. Thanks.<\/p><div id=\"linux-2767987759\" class=\"linux-after-8th-paragraph linux-entity-placement\" style=\"margin-top: 15px;margin-bottom: 15px;\"><a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting\/?mtm_campaign=blogs&#038;mtm_source=lhs&#038;mtm_medium=blog&#038;mtm_content=managed-vps&#038;mtm_cid=1340&#038;mtm_placement=inline\" aria-label=\"Untitled\"><img src=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622.jpg\" alt=\"\"  srcset=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622.jpg 728w, https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2020\/12\/1340095_VPSGoogleAds_728x90_042622-300x37.jpg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" width=\"728\" height=\"90\"  style=\"display: inline-block;\" \/><\/a><\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>The 502 Bad Gateway error is an HTTP status code that means that one server received an invalid response from another server. In more technical words, A 502 Bad Gateway means that the proxy (gateway) server wasn\u2019t able to get a valid or any response from the upstream server. If you are seeing a 502 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1496,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[196,195,197,22],"class_list":["post-1494","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-502-error","tag-fix","tag-gateway-error","tag-nginx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Fix &#039;502 Bad Gateway&#039; Error In Nginx | LinuxHostSupport<\/title>\n<meta name=\"description\" content=\"In this tutorial, you can learn how to fix the &#039;502 bad gateway&#039; error in Nginx, without technical difficulties, step-by-step.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-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 &#039;502 Bad Gateway&#039; Error In Nginx | LinuxHostSupport\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you can learn how to fix the &#039;502 bad gateway&#039; error in Nginx, without technical difficulties, step-by-step.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxHostSupport\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/linuxhostsupport\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-15T17:30:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"372\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How To Fix &#039;502 Bad Gateway&#039; Error In Nginx | LinuxHostSupport\" \/>\n<meta name=\"twitter:description\" content=\"In this tutorial, you can learn how to fix the &#039;502 bad gateway&#039; error in Nginx, without technical difficulties, step-by-step.\" \/>\n<meta name=\"twitter:creator\" content=\"@lnxhostsupport\" \/>\n<meta name=\"twitter:site\" content=\"@lnxhostsupport\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\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\":\"Article\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/#\\\/schema\\\/person\\\/53a9571ea078cdf350137a1e97423cfb\"},\"headline\":\"How To Fix \u201c502 Bad Gateway\u201d Error In Nginx\",\"datePublished\":\"2021-08-15T17:30:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/\"},\"wordCount\":1028,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/how-to-fix-502-bad-gateway-error-in-nginx.jpg\",\"keywords\":[\"502 error\",\"fix\",\"gateway error\",\"nginx\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/\",\"url\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/\",\"name\":\"How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/how-to-fix-502-bad-gateway-error-in-nginx.jpg\",\"datePublished\":\"2021-08-15T17:30:30+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/#\\\/schema\\\/person\\\/53a9571ea078cdf350137a1e97423cfb\"},\"description\":\"In this tutorial, you can learn how to fix the '502 bad gateway' error in Nginx, without technical difficulties, step-by-step.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/how-to-fix-502-bad-gateway-error-in-nginx.jpg\",\"contentUrl\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/how-to-fix-502-bad-gateway-error-in-nginx.jpg\",\"width\":742,\"height\":372,\"caption\":\"how to fix 502 bad gateway error in nginx\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/how-to-fix-502-bad-gateway-error-in-nginx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Fix \u201c502 Bad Gateway\u201d Error In Nginx\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/\",\"name\":\"LinuxHostSupport\",\"description\":\"Linux Tutorials and Guides\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/#\\\/schema\\\/person\\\/53a9571ea078cdf350137a1e97423cfb\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/linuxhostsupport.com\\\/blog\\\/author\\\/r0s3admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport","description":"In this tutorial, you can learn how to fix the '502 bad gateway' error in Nginx, without technical difficulties, step-by-step.","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:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/","og_locale":"en_US","og_type":"article","og_title":"How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport","og_description":"In this tutorial, you can learn how to fix the '502 bad gateway' error in Nginx, without technical difficulties, step-by-step.","og_url":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/","og_site_name":"LinuxHostSupport","article_publisher":"https:\/\/www.facebook.com\/linuxhostsupport","article_published_time":"2021-08-15T17:30:30+00:00","og_image":[{"width":742,"height":372,"url":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_title":"How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport","twitter_description":"In this tutorial, you can learn how to fix the '502 bad gateway' error in Nginx, without technical difficulties, step-by-step.","twitter_creator":"@lnxhostsupport","twitter_site":"@lnxhostsupport","twitter_misc":{"Written by":"admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#article","isPartOf":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/"},"author":{"name":"admin","@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb"},"headline":"How To Fix \u201c502 Bad Gateway\u201d Error In Nginx","datePublished":"2021-08-15T17:30:30+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/"},"wordCount":1028,"commentCount":0,"image":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg","keywords":["502 error","fix","gateway error","nginx"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/","url":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/","name":"How To Fix '502 Bad Gateway' Error In Nginx | LinuxHostSupport","isPartOf":{"@id":"https:\/\/linuxhostsupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#primaryimage"},"image":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg","datePublished":"2021-08-15T17:30:30+00:00","author":{"@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb"},"description":"In this tutorial, you can learn how to fix the '502 bad gateway' error in Nginx, without technical difficulties, step-by-step.","breadcrumb":{"@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#primaryimage","url":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg","contentUrl":"https:\/\/linuxhostsupport.com\/blog\/wp-content\/uploads\/2021\/07\/how-to-fix-502-bad-gateway-error-in-nginx.jpg","width":742,"height":372,"caption":"how to fix 502 bad gateway error in nginx"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxhostsupport.com\/blog\/how-to-fix-502-bad-gateway-error-in-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxhostsupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Fix \u201c502 Bad Gateway\u201d Error In Nginx"}]},{"@type":"WebSite","@id":"https:\/\/linuxhostsupport.com\/blog\/#website","url":"https:\/\/linuxhostsupport.com\/blog\/","name":"LinuxHostSupport","description":"Linux Tutorials and Guides","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxhostsupport.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/linuxhostsupport.com\/blog\/#\/schema\/person\/53a9571ea078cdf350137a1e97423cfb","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed83c63a34114218f977e1f913be03906d17c7d9c800788fcac345f5edaf6cfa?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/linuxhostsupport.com\/blog\/author\/r0s3admin\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/comments?post=1494"}],"version-history":[{"count":4,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1494\/revisions"}],"predecessor-version":[{"id":1505,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/posts\/1494\/revisions\/1505"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/media\/1496"}],"wp:attachment":[{"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/media?parent=1494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/categories?post=1494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostsupport.com\/blog\/wp-json\/wp\/v2\/tags?post=1494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}