title: How to fix nginx 502 bad gateway error?
body: <p>I have set up a nginx server several weeks ago, at that time <code>http://180.76.117.109/1/#/home</code> worked well.</p>
  
  <p>However, when I recheck that today in a browser, it returns an <code>502 bad gateway</code> error.</p>
  
  <p>Here is the result of <code>sudo tail -30 /var/log/nginx/error.log</code>:</p>
  
  <pre><code>2018/03/26 10:13:12 [error] 9456#9456: *2580202 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "GET /?season=1&amp;league_id=1'%20AND%20(SELECT%20*%20FROM%20(SELECT(SLEEP(5)))oUvL)%20AND%20'kSYX'='kSYX&amp;match_day=1&amp;team_id=1 HTTP/1.0", upstream: "http://127.0.0.1:3000/?season=1&amp;league_id=1'%20AND%20(SELECT%20*%20FROM%20(SELECT(SLEEP(5)))oUvL)%20AND%20'kSYX'='kSYX&amp;match_day=1&amp;team_id=1", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580204 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "POST /wp-admin/admin-ajax.php?action=duplicator_package_delete HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin-ajax.php?action=duplicator_package_delete", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580206 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "GET /wp-admin/admin.php?page=wpseo_bulk-editor&amp;type=title&amp;orderby=post_date&amp;order=asc HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin.php?page=wpseo_bulk-editor&amp;type=title&amp;orderby=post_date&amp;order=asc", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580208 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.163, server: _, request: "GET /?action=data_management&amp;cpmvc_do_action=mvparse&amp;f=datafeed&amp;method=remove&amp;rruleType=del_only&amp;calendarId=1%20AND%20(SELECT%20*%20FROM%20(SELECT(SLEEP(5)))nDnr) HTTP/1.0", upstream: "http://127.0.0.1:3000/?action=data_management&amp;cpmvc_do_action=mvparse&amp;f=datafeed&amp;method=remove&amp;rruleType=del_only&amp;calendarId=1%20AND%20(SELECT%20*%20FROM%20(SELECT(SLEEP(5)))nDnr)", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580210 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "GET /wp-admin/admin-ajax.php HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin-ajax.php", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580212 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "GET /wp-admin/admin.php HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin.php", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580214 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "POST /wp-admin/admin-ajax.php?action=duplicator_package_delete HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin-ajax.php?action=duplicator_package_delete", host: "180.76.117.109:80"
  2018/03/26 10:13:12 [error] 9456#9456: *2580216 connect() failed (111: Connection refused) while connecting to upstream, client: 180.97.106.39, server: _, request: "GET /wp-admin/admin.php?page=wpseo_bulk-editor&amp;type=title&amp;orderby=post_date%2c(select%20*%20from%20(select(sleep(5)))a)&amp;order=asc HTTP/1.0", upstream: "http://127.0.0.1:3000/wp-admin/admin.php?page=wpseo_bulk-editor&amp;type=title&amp;orderby=post_date%2c(select%20*%20from%20(select(sleep(5)))a)&amp;order=asc", host: "180.76.117.109:80"
  2018/03/26 10:48:39 [error] 9456#9456: *2580218 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 10:48:39 [error] 9456#9456: *2580218 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 10:48:51 [error] 9456#9456: *2580218 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 10:48:51 [error] 9456#9456: *2580218 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 10:51:22 [error] 9456#9456: *2580223 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 10:51:22 [error] 9456#9456: *2580223 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:07:58 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:07:58 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:07:59 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:07:59 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:07:59 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:07:59 [error] 9456#9456: *2580226 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:08:18 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:08:18 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:08:19 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:08:19 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:08:20 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:08:20 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:08:30 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:08:30 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  2018/03/26 11:08:31 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /1/ HTTP/1.1", upstream: "http://127.0.0.1:3000/1/", host: "180.76.117.109"
  2018/03/26 11:08:32 [error] 5593#5593: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 175.169.4.93, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "180.76.117.109", referrer: "http://180.76.117.109/1/"
  </code></pre>
  
  <p>Does anyone know what may be the problem?</p>