title: AWS ElasticBeanstalk NodeJS - 502 error: recv() failed (104: Connection reset by peer) while reading response header from upstream
body: <p>We are planning to migrate our NodeJS platform from plain EC2 to ElasticBeanstalk. During these process, after some struggles, we have deployed our app and able to access and perform actions. However, for some requests, we <strong>received 502 error</strong>.</p>
  
  <p>After checking the logs we found below;</p>
  
  <hr>
  
  <h2>/var/log/nginx/error.log</h2>
  
  <p>2020/03/16 06:12:09 [error] 3009#0: *119488 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxx.xx.xx.xxx, server: , request: "POST /www_auth/register HTTP/1.1", upstream: "<a href="http://127.0.0.1:8081/register" rel="nofollow noreferrer">http://127.0.0.1:8081/register</a>", host: "****.us-east-2.elasticbeanstalk.com"</p>
  
  <p>It occurs in randomly and I don't have any clue. I feel some configuration level changes I missed/need to add with nginx. </p>
  
  <p>If you have any steps/suggestions to solve this, appreciate it!</p>