Search code examples
asp.net-mvcasp.net-coreiisweb-deploymentkestrel-http-server

IIS website : error trying to access site in browser (Kestrel problem)


I created a site in ASP.NET Core with VisualStudio and then copied the files to the server and linked IIS (8.5) to it.

I configured a binding with localhost:443.

However, when I browse to https://localhost:443 I obtain an error:

An error occurred while starting the application with the following message:

.NET Core 4.6.28008.01 X64 v4.0.0.0    |   Microsoft.AspNetCore.Hosting version 2.1.1-rtm-30846    |    Microsoft Windows 6.3.9600    |   Need help? 

When I access the site via dotnet .\MVF2.dll, I obtain the following critical error:

crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.EndpointsStrategy.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

What's happening with Kestrel?

To see my Program.cs, Startup.cs and web.config see question https://stackoverflow.com/questions/59986062/website-deployment-via-iis-cant-access-site


Solution

  • I solved the problem. It was a problem with the app and connection strings.

    I inserted in the web.config file in the server the option stdoutLogEnabled="true" and then saw the error in the log files.

    This option is in the line of the file that says:

    <aspNetCore processPath=".\myapp.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />