DEV Community

Dennis Quesada Cruz
Dennis Quesada Cruz

Posted on

Can't change Kestrel default listening port when publishing.

Hello community, it turns out that I have an app with Netcore3.0 which I want to publish on a linux server. In my development environment, Kestrel works perfectly listening on port 5050, when it runs in the (local) production environment, it also listens on 5050.
The problem is when it is published, which somehow does not preserve the value of the established port, and starts listening to the default port.

This is the command I use to publish:

dotnet publish --configuration Release

  • Apparently my environment variables are fine.
  • I have checked the json file launchSettings and ensured that it is fine.
  • I tried copying the appsettings jsons for the / bin / Release / netcoreapp3 / directory and it doesn't work.
  • Tried adding

Could you guide me in what other way I can change the default port of Kestrel or where else should I check again?

Discussion (2)

djnitehawk profile image

give this a try

dcruz1990 profile image
Dennis Quesada Cruz Author

Excelent!!! I added a Kestrel section on appsettings.Production and everything goes fine 👌
Thanks a lot!!!