Reputation: 20947
My ASP.NET Core 2.1 webapp works perfectly on my dev setup. Now I want to test it in production.
The production server is Ubuntu 18. I followed the instructions. I don't want to setup nginx yet, just do some quick tests, and the instructions say:
"Either configuration—with or without a reverse proxy server—is a valid and supported hosting configuration for ASP.NET Core 2.0 or later apps".
So I built and published my project: dotnet publish --configuration Release
.
Then on the server:
/var/www/myapp
)sudo uwf allow 5000/tcp 80/tcp
dotnet MyApp.dll
(also tried sudo dotnet MyApp.dll
)It runs without errors/warnings, and says it's listening on http://localhost:5000
.
On my local machine I tried http://serveripaddress
(and http://serveripaddress:5000
) but get nothing ("can't connect"). I can access that server with ssh, sftp, etc - only http isn't working.
What am I doing wrong?
Upvotes: 2
Views: 1593
Reputation: 20947
Found the problem. I needed to use:
ASPNETCORE_URLS="http://0.0.0.0:5000" sudo dotnet MyApp.dll
Then it logs Now listening on: http://0.0.0.0:5000
. And I can access that from a remote client.
Upvotes: 4
Reputation: 3050
the host default bind is 127.0.0.1 , so you can only access the app locally. if you want to access it from Network, please add --urls
parameter. for example :
for development, you can run:
dotnet run --urls http://0.0.0.0:5000
and for deployed project, you can run:
dotnet MyApp.dll --urls http://0.0.0.0:5000
The dotnet core sdk I use is version 2.1.400.
Upvotes: 6