当使用.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() `
发布于 2020-02-11 19:58:08
也可以在这里检查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
发布于 2020-07-21 15:09:26
在Windows Update之后,某些端口由Windows保留,应用程序无法绑定到这些端口。请检查此命令以获取Os上的禁用端口
netsh interface ipv4 show excludedportrange转换protocol=tcp
发布于 2019-09-11 12:06:06
当您直接通过ASP.NET运行Kestrel核心应用程序时,不需要额外的反向代理,如IIS或nginx,您将需要正确配置托管URL。
问题是,您没有遵循Kestrel web服务器中的端口共享限制。
当您要使用Kestrel web服务器时,您应该将唯一端口设置为app。(如果您使用端口80,请确保没有应用程序使用此端口)。而且你的应用程序也有足够的权限。
更多信息:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.2
我希望这是有用的。
https://stackoverflow.com/questions/54671199
复制相似问题