0
votes

I've dotnet core 3.1 project. I launched a few machines on iis. But today i can't launched the app on iis. I can launch with "dotnet <app.dll>" command and everything's good. But when i launch on IIS, it gives this 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)"

Any suggestion ?

PS: I checked my ports in use with command netstat -o. There is no using from any application

2
stackoverflow.com/questions/68272081/… Sounds like the same issue. - Lex Li
I tried but nothing happened - Hasan Özkaynak
It may be caused by a firewall, you can try to disable the firewall and try again. - samwu
Customer is using Windows Defender. I tried when Defender closed but nothing happened. App is running with dotnet command correctly but didnt work on iis - Hasan Özkaynak
You can try to use netsh interface ipv4 show excludedportrange protocol=tcp to list the reserved ranges. - samwu

2 Answers

0
votes

Finally I found my solution on my own. I removed UseKestrel() line from program.cs and everything's good.

        var config = new ConfigurationBuilder().AddCommandLine(args).Build();

       return  Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
                webBuilder.UseKestrel(); **//remove this line.**
                webBuilder.UseUrls();
                webBuilder.UseIISIntegration();
                
            }).ConfigureServices((context, services) =>
            {
                services.AddHostedService<Worker>();
                services.AddHostedService<MonitorWorker>();
                services.AddHostedService<TransferWorker>();
            });

    }
0
votes

netsh interface ipv4 show excludedportrange protocol=tcp

Look at the ports listed and see if it overlaps with your port.

If so, rebooting your PC or changing the port has fixed this for me.

I'm using port 56240, Windows Update sometimes takes that range.