Reputation: 633
I need to run my asp.net core api on port 5003, how to do this? (port 5000 is already in used by another asp.het core api)
I am facing with : : Unhandled Exception: System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in used
below is my launchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5003",
"sslPort": 5002
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"myapp": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5003;https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
and my startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseHsts();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}");
});
Upvotes: 1
Views: 617
Reputation: 11841
Set it with UseUrls
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://*:5003");
Upvotes: 1