title: AWS ELB keeps returning 404 Health checks failed with these codes: [404]
body: <p>I'm serving my node js application with pm2.</p>
  <p>nginx.conf file is</p>
  <pre><code>user nginx;
  worker_processes auto;
  error_log /var/log/nginx/error.log;
  pid /run/nginx.pid;
  
  # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
  include /usr/share/nginx/modules/*.conf;
  
  events {
      worker_connections 1024;
  }
  
  http {
      log_format  main  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
                        '$status $body_bytes_sent &quot;$http_referer&quot; '
                        '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile            on;
      tcp_nopush          on;
      tcp_nodelay         on;
      keepalive_timeout   65;
      types_hash_max_size 4096;
  
      include             /etc/nginx/mime.types;
      default_type        application/octet-stream;
  
      # Load modular configuration files from the /etc/nginx/conf.d directory.
      # See http://nginx.org/en/docs/ngx_core_module.html#include
      # for more information.
      include /etc/nginx/conf.d/*.conf;
  
      server {
          listen       80;
          listen       [::]:80;
          server_name  _;
          root         /usr/share/nginx/html;
          # Load configuration files for the default server block.
          #include /etc/nginx/default.d/*.conf;
  
          error_page 404 /404.html;
              location = /40x.html {
          }
  
          error_page 500 502 503 504 /50x.html;
              location = /50x.html {
          }
      }
  }
  </code></pre>
  <p>and inside the **<code>conf.d/</code>**folder I have create configuration file like below (with the name of api.conf)</p>
  <pre><code>server {
      listen 80;
      server_name dev.xxxxxxx.com;
      underscores_in_headers on;
        #  return 301 https://$host$request_uri;
          location / {
          proxy_pass http://localhost:3004/;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
       }
  }
  </code></pre>
  <p>when I stop the node application <strong><code>nginx server the ELB Health status is 502</code></strong> and start when I start the  nginx server then <strong><code>nginx server the ELB Health status is 404</code></strong></p>
  <p>I'm not able to find what is the issue. Could any one please help me to understand and solve</p>
  <p>even I checked nginx error logs as below</p>
  <pre><code>[02/Feb/2021:17:21:29 +0000] &quot;GET / HTTP/1.1&quot; 502 157 &quot;-&quot; &quot;ELB-HealthChecker/2.0&quot; &quot;-&quot;
  [02/Feb/2021:17:21:38 +0000] &quot;GET / HTTP/1.1&quot; 404 60 &quot;-&quot; &quot;ELB-HealthChecker/2.0&quot; &quot;-&quot;
  </code></pre>