Search code examples
c#.net-corekestrel

Unable to start Kestrel. System.FormatException: Invalid URL: 'http:////*:80'


I am unable to start dotnet core app after i publish the app. While dotnet run starts the app in development env, attempt to start the app after publishing would only throw this error.

crit: Microsoft.AspNetCore.Server.Kestrel[0]
  Unable to start Kestrel.
System.FormatException: Invalid URL: 'http:////*:80'.
at Microsoft.AspNetCore.Server.Kestrel.Core.ServerAddress.FromUrl(String url)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.ParseAddress(String address, Boolean& https)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

Unhandled Exception: System.FormatException: Invalid URL: 'http:////*:80'.
at Microsoft.AspNetCore.Server.Kestrel.Core.ServerAddress.FromUrl(String url)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.ParseAddress(String address, Boolean& https)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.ValidateOptions()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at NiqVive.Api.Program.Main(String[] args) in /home/sav/github/nForTics/NiqVive/NiqVive.Api/Program.cs:line 12
[1]    29044 abort (core dumped)  dotnet NiqVive.Api.dll

This is my Program.cs

namespace NiqVive.Api
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseKestrel(options =>
                    {                    
                        options.Listen(IPAddress.Any, 5007);
                        options.Limits.MaxRequestBodySize = null;
                    })

                .UseDefaultServiceProvider(options => {
                    options.ValidateScopes = false;
                });

    }
}

--hardware Version: 2.1.401

Runtime Environment: OS Name: ubuntu OS Version: 18.04 RID: ubuntu.18.04-x64 Base Path: /usr/share/dotnet/sdk/2.1.401/

It doesn't start if I publish the app.


Solution

  • go to Properties Folder and Open the launchSetting.json file change port number with some else in "applicationUrl": "http://localhost:5001;http://localhost:4000", here we have http://localhost:5000 change it to another port