title: How to solve 502 Bad Gateway error while deploying app in Heroku
body: <p>I just wanted to test a simple HTML 1 page webapp in the Heroku cloud. <strong><em>Heroku and Nginx is new to me</em></strong>. 
  I have used Nginx Buildpack and once the app is deploying, I am getting 502 Bad Gateway error.</p>
  
  <p>I tried to check and the logs and found the below error. </p>
  
  <pre><code>2019-11-04T15:29:27.937072+00:00 app[web.1]: 2019/11/04 15:29:27 [crit] 20#0: *14 connect() to unix:/tmp/nginx.socket failed (2: No such file or directory) while connecting to upstream, client: 10.5.179.3, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/tmp/nginx.socket:/favicon.ico", host: "someting.herokuapp.com", referrer: "https://someting.herokuapp.com/testpage_text.html"
  </code></pre>
  
  <p>/tmp is there on the server. Below is the default configuration.</p>
  
  <pre><code>daemon off;
  #Heroku dynos have at least 4 cores.
  worker_processes &lt;%= ENV['NGINX_WORKERS'] || 4 %&gt;;
  
  events {
      use epoll;
      accept_mutex on;
      worker_connections &lt;%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %&gt;;
  }
  
  http {
          gzip on;
          gzip_comp_level 2;
          gzip_min_length 512;
  
      server_tokens off;
  
      log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
      access_log &lt;%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %&gt; l2met;
      error_log &lt;%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %&gt;;
  
      include mime.types;
      default_type application/octet-stream;
      sendfile on;
  
      #Must read the body in 5 seconds.
      client_body_timeout 5;
  
      upstream app_server {
          server unix:/tmp/nginx.socket fail_timeout=0;
      }
  
      server {
          listen &lt;%= ENV["PORT"] %&gt;;
          server_name _;
          keepalive_timeout 5;
  
          location / {
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $http_host;
              proxy_redirect off;
              proxy_pass http://app_server;
          }
      }
  }
  </code></pre>
  
  <p>Do I need to change or add anything to "upstream app_server" in the configuration to make the site work?</p>
  
  <p>Thanks in advance for your help!</p>