I'm trying to debug a Microservice.When running from VS,it launches in the port set in LaunchSettings.json
,but when running using the exe
, all microservices starts from port 5001
.
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5004",
"sslPort": 44345
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"myapp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5004",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Kestrel server is configured to run dotnet core app on 5000 and 5001. But you can override it by providing command line argument --urls while executing exe. You can read it more on Setting Up Kestrel
Alternate way to override default port is to run it from cmd.
Suppose your exe's name is webapi then to override default port open cmd and go to the folder where exe is located and run
webapi.exe --urls http://localhost:port. Port is integer value where kestrel will start listening.