红隼无法启动

Pin*_*ong 8 c# kestrel-http-server

当指定要绑定的端口时,.UseKestrel()我得到下面列出的错误..但是如果我删除 kestrel 选项,如果我从浏览器检查 API,一切正常。

我尝试绑定到我的应用程序默认使用的端口而不选择netstat任何端口,并且我尝试检查以主动避免任何正在使用的端口。除了完全删除选项外,什么都不起作用。这不会在我的 Mac 或另一台 Windows 10 机器上复制。此设备是 Windows 10。

.UseKestrel(options =>
{
    options.Listen(IPAddress.Loopback, 50470);
    options.Listen(IPAddress.Any, 80);
})

: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://localhost:50470/'. Binding to endpoints defined 
in UseKestrel() instead.
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__DisplayClass21_01.<<StartAsync>g__OnBind|0>d.MoveNext() ` 
Run Code Online (Sandbox Code Playgroud)

nor*_*gie 19

还可以在这里查看 Darkthread 的答案:https ://superuser.com/questions/1486417/unable-to-start-kestrel-getting-an-attempt-was-made-to-access-a-socket-in-a-way

我们发现我们使用了很长时间的端口不再可以访问,因为它已被 Windows 保留!您可能希望使用以下命令检查保留端口: netsh interface ipv4 show excludedportrange protocol=tcp


小智 6

Windows Update 后,某些端口被 Windows 保留,应用程序无法绑定到这些端口。请检查此命令以了解操作系统上的禁止端口

netsh 接口 ipv4 显示排除的端口范围协议=tcp


Pin*_*ong -1

问题出在端口 80 的附加绑定上,更新此解决方案解决了该问题。