Question

Hi, Im getting connection Refused error on Nginx and dotnet combination.

Here is my Nginx config.


server {
    listen        80;
    server_name 139.59.90.155;                                                                                                                  location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }

    location /manage {
        proxy_pass http://127.0.0.1:5000/manage;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;

    }
}

I am able to curl to the dotnet application inside the droplet. But refuses to connect via a browser.

  1. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  2. tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12063/nginx: master
  3. tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 640/systemd-resolve
  4. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 820/sshd
  5. tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 10928/dotnet
  6. tcp 0 0 127.0.0.1:5001 0.0.0.0:* LISTEN 10928/dotnet
  7. tcp 0 340 139.59.90.155:22 83.137.200.73:63066 ESTABLISHED 3082/sshd: root@pts
  8. tcp 0 1080 139.59.90.155:22 222.186.42.155:53686 ESTABLISHED 12043/sshd: [accept
  9. tcp6 0 0 :::22 :::* LISTEN 820/sshd
  10. tcp6 0 0 ::1:5000 :::* LISTEN 10928/dotnet
  11. tcp6 0 0 ::1:5001 :::* LISTEN 10928/dotnet
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @samynmhd:

I managed to fix, just hand to change the Progam.cs file. Added UseUrls() and its working now.

       public static IHostBuilder CreateHostBuilder(string[] args) =>
           Host.CreateDefaultBuilder(args)
               .ConfigureWebHostDefaults(webBuilder =>
               {
                   webBuilder.UseStartup<Startup>().UseUrls("http://*:5000");
               });

View the original comment