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.
- Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
- tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12063/nginx: master
- tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 640/systemd-resolve
- tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 820/sshd
- tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 10928/dotnet
- tcp 0 0 127.0.0.1:5001 0.0.0.0:* LISTEN 10928/dotnet
- tcp 0 340 139.59.90.155:22 83.137.200.73:63066 ESTABLISHED 3082/sshd: root@pts
- tcp 0 1080 139.59.90.155:22 222.186.42.155:53686 ESTABLISHED 12043/sshd: [accept
- tcp6 0 0 :::22 :::* LISTEN 820/sshd
- tcp6 0 0 ::1:5000 :::* LISTEN 10928/dotnet
- tcp6 0 0 ::1:5001 :::* LISTEN 10928/dotnet
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.
×
Hi @samynmhd - that is indeed mysterious, what do the logs say?
For example, run:
tail -f /var/log/nginx/error.log
and attempt to access the site again, what errors come up? If nothing, run:tail -f /var/log/nginx/access.log
to watch the regular access logs and try again. What comes up then?@AHA, This is what i get on error log.
I managed to fix, just hand to change the Progam.cs file. Added UseUrls() and its working now.
Hi there @samynmhd,
Thanks for sharing the solution with the community!
Indeed as far as I can see from your
netstat
command, your dotnet application was binding on127.0.0.1:5000
this is why you are not able to access it directly from outside the Droplet.By changing your URL to
("http://*:5000");
your dotnet application is now binding on0.0.0.0:5000
and it is accessible via the outside world.If you now run
netstat -plant
again, you should be able to see the following output:Hope that this helps!
Regards,
Bobby