0
votes

I'm incredibly new .NET apps, so this is probably easily fixed. I'm only venturing into this world because I really want to try Blazor.

I have an Ubuntu server on AWS Lightsail and I'm trying to get set up so I can start actually coding. I installed .NET Core 3.1 (and .NET Runtime 3.1), created a directory in /home called DuckGoose and ran dotnet new blazorserver. Finally, I ran dotnet publish --configuration Release.

According to this, that is all I need.

I went to the release folder and ran dotnet DuckGoose.dll, and the app started. Everything seems normal from this side.

However, when I go to http://lightsail_provided_ip:5000, the server refuses the connection. I have no idea why.

Thank you in advance for your help - I am in a new world and I am completely lost.

(I have a firewall rule on Lightsail to allow inbound traffic to ports 5000-5001 with TCP)

NOTE: I also had nginx running from before I did all this, but I killed it and the problem is still present.

1
Port 80, not 5000.Hans Passant
@HansPassant Everywhere I found it said 5000 though, including in the project configuration files? Regardless, I tried with 80 and still connection refused (unless nginx is on)Raf

1 Answers

2
votes

The problem is that your project is listening on the loopback address, so external devices cannot connect to that service listening on loopback address.

There are two ways to fix this for cloud server:

  1. Configure your Nginx to set up a reverse proxy to your service that is listening on a loopback address if you intend on using Nginx. Your link have the necessary instructions for you to set it up.

  2. You can change the loopback address to '0.0.0.0' which would have the service listening on all address. This can be done by going to your project directory, open Properties folder, and then edit launchSettings.json file and change the following line:

"applicationUrl": "https://localhost:5001;http://localhost:5000",

TO

"applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000",

Then you'll be able to connect to your website by going to http://lightsail_provided_ip:5000

Side note: Generally, it's recommended to use Apache or Nginx to handle public facing connections and reverse proxy to your Dotnet Kestrel Server that is listening on loopback address. Kestrel is still a work in progress web server while Nginx and Apache are battle tested servers also it's generally easier to configure HTTPS for those servers.