Curl can download Nginx Virtual Host Site but browser gets connection refused

Posted July 1, 2019 5.3k views
NginxNode.jsUbuntu 18.04

I have configured nginx according to this tutorial and additionally I have changed the location to reverse proxy to my nuxt.js application on localhost:3000 according to this tutorial. I can

curl -i 

and it returns the full header of the site plus all of the html and css. Header is

HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Mon, 01 Jul 2019 00:04:41 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 301997
Connection: keep-alive
ETag: "49bad-bEI6OAceinKEf1RyUfL3hbl/M3k"
Accept-Ranges: none

If i access through the browser I get ERRCONNECTIONREFUSED.

I cannot for the life of me figure out what is wrong. My /etc/nginx/sites-available/ file is the following

server {
        listen 80;
        listen [::]:80;

        root /var/www/;
        index index.html index.htm index.nginx-debian.html;


        location / {
                #try_files $uri $uri/ =404;
                proxy_pass http://localhost:3000;
                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;

There is a proper sysmlink in /etc/nginx/sites-enabled/.
I tested the setting the location in the default server and I can access the site no problem (using the ip address of the machine). But if I go through the virtual host then I cannot connect via browser.

What am I missing?

  • Hi there @seanaye2,

    With both CURL and a browser, now gives an Nginx 502 Bad Gateway page, do you still require help?

  • @MattIPv4 Thanks for your reply. Yes I still require help. The node process was down which is why you received 502. I have now daemonized the process with pm2. I can curl the app but still cannot access through any browser.

  • @seanaye2 how very odd. Have you tried using an incognito tab in your browser or an altogether different browser?

    When I attempt to access your site through my browser, I am greeted by your vuetify storefront

    - Matt.

  • I have added the hostname and added the same proxy config to the default server. I can access the site through a browser at which means the default server works fine but the virtual one at does not.

  • @MattIPv4 Very strange I have tried Chrome, Safari, and Brave (built on Chromium). None of them work in standard tabs but all of them work in incognito tabs. Do you have any idea why that would be? Does it have something to do with lack of https? I know that is my next step I need to setup. Thanks.

    – Sean

  • Show 2 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

This question was answered by @seanaye2:

SOLVED: I used certbot to automatically add an SSL certificate to my site. I also added the hostname in my DNS settings as I only had before. I’m not sure which of these fixed the problem but the site now functions as expected.

View the original comment