title: Node js api deployment on digital ocean server
body: <p>Trying to deploy my node js api onto digital ocean using ngnix i can log into my server through ssh fine, Its only when i try to access my server from a browser i get a 502 error i run logs on the command line and this is what is logged to the console</p>
  <pre><code>
  
  2022/03/28 16:14:37 [error] 1312008#1312008: *20 connect() failed (111: Connection refused) while connecting to upstream, client: 192.53.170.243, server: telebotstools.io, request: &quot;GET / HTTP/1.1&quot;, upstream: &quot;http://[::1]:5000/&quot;, host: &quot;188.166.14.11&quot;
  2022/03/28 16:30:25 [error] 1399533#1399533: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 71.183.157.83, server: telebotstools.io, request: &quot;GET / HTTP/1.1&quot;, upstream: &quot;http://[::1]:8080/&quot;, host: &quot;telebotstools.io&quot;
  2022/03/28 16:30:25 [error] 1399533#1399533: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 71.183.157.83, server: telebotstools.io, request: &quot;GET / HTTP/1.1&quot;, upstream: &quot;http://127.0.0.1:8080/&quot;, host: &quot;telebotstools.io&quot;
  2022/03/28 16:35:41 [error] 1399533#1399533: *4 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 71.183.157.83, server: telebotstools.io, request: &quot;GET / HTTP/1.1&quot;, upstream: &quot;http://127.0.0.1:8080/&quot;, host: &quot;telebotstools.io&quot;
  2022/03/28 16:36:41 [error] 1399533#1399533: *4 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 71.183.157.83, server: telebotstools.io, request: &quot;GET / HTTP/1.1&quot;, upstream: &quot;http://[::1]:8080/&quot;, host: &quot;telebotstools.io&quot;
  </code></pre>
  <p>I've tried to troubleshoot the problem with no luck </p>
  <p>I have restarted the server checked logs rewritten my config file multiple times with no luck</p>
  <p>i followed this <a href="https://coderrocketfuel.com/article/create-and-deploy-an-express-rest-api-to-a-digitalocean-server" rel="nofollow noreferrer">url</a> to the T and i still cant seem to trouble shoot the problem</p>
  <pre><code>server {
          listen 80 default_server;
          listen [::]:80 default_server;
  
          # include snippets/snakeoil.conf;
  
          root /var/www/html;
  
          # Add index.php to the list if you are using PHP
          index index.html index.htm index.nginx-debian.html;
  
          server_name telebotstools.io www.telebotstools.io;
  
     location / {
          proxy_pass http://localhost:8080; #whatever port your app runs on
          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>Thanks in advance</p>