无法在 macOS Monterey 上启动 Kestrel
Unable to start Kestrel on macOS Monterey
我将我的 macOS Big Sur
升级到 macOS Monterey
然后我尝试 运行 我的 .Net Core 应用程序 ASPNETCORE_URLS=http://*:5000
配置它给我错误如下
2021-10-27 19:23:25.0068|FATAL|Microsoft.AspNetCore.Server.Kestrel|Unable to start Kestrel.
Unhandled exception. System.IO.IOException: Failed to bind to address http://[::]:5000: address already in use.
---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
当我尝试使用以下代码查找监听端口 5000
的人时
sudo lsof -nP -i:5000 | grep LISTEN
结果是;
ControlCe 2874 sametcelikbicak 17u IPv4 0xac23fd083a725c89 0t0 TCP *:5000 (LISTEN)
ControlCe 2874 sametcelikbicak 18u IPv6 0xac23fd082e8a6671 0t0 TCP *:5000 (LISTEN)
然后我尝试用 kill 命令杀死那个 listen,如下所示
kill -9 2874
端口侦听不会终止,我再次 运行 sudo lsof -nP -i:5000 | grep LISTEN
进行测试,但它再次给了我那个结果
ControlCe 4271 sametcelikbicak 17u IPv4 0xac23fd0849ef2c59 0t0 TCP *:5000 (LISTEN)
ControlCe 4271 sametcelikbicak 18u IPv6 0xac23fd083995b411 0t0 TCP *:5000 (LISTEN)
如果我尝试 ASPNETCORE_URLS=http://*:5001
到 运行 .Net Core 应用程序它工作,我也重新启动我的 mac 但仍然给出错误,为什么 ASPNETCORE_URLS=http://*:5000
配置不起作用使用 Monterey
并且始终使用端口 5000
还有我的 dotnet 版本和 sdk-list 如下
➜ ~ dotnet --list-sdks
2.1.4 [/usr/local/share/dotnet/sdk]
2.1.402 [/usr/local/share/dotnet/sdk]
2.1.504 [/usr/local/share/dotnet/sdk]
3.1.201 [/usr/local/share/dotnet/sdk]
3.1.300 [/usr/local/share/dotnet/sdk]
5.0.102 [/usr/local/share/dotnet/sdk]
5.0.103 [/usr/local/share/dotnet/sdk]
5.0.300 [/usr/local/share/dotnet/sdk]
➜ ~ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
➜ ~ dotnet --version
5.0.300
➜ ~
感谢任何建议。
感谢 @devNull, AirPlay in the Control Center 解决方案解决了我的问题。
解决方案的基本步骤;
转到系统偏好设置 > 共享 > 取消选中 AirPlay Receiver
我将我的 macOS Big Sur
升级到 macOS Monterey
然后我尝试 运行 我的 .Net Core 应用程序 ASPNETCORE_URLS=http://*:5000
配置它给我错误如下
2021-10-27 19:23:25.0068|FATAL|Microsoft.AspNetCore.Server.Kestrel|Unable to start Kestrel.
Unhandled exception. System.IO.IOException: Failed to bind to address http://[::]:5000: address already in use.
---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
当我尝试使用以下代码查找监听端口 5000
的人时
sudo lsof -nP -i:5000 | grep LISTEN
结果是;
ControlCe 2874 sametcelikbicak 17u IPv4 0xac23fd083a725c89 0t0 TCP *:5000 (LISTEN)
ControlCe 2874 sametcelikbicak 18u IPv6 0xac23fd082e8a6671 0t0 TCP *:5000 (LISTEN)
然后我尝试用 kill 命令杀死那个 listen,如下所示
kill -9 2874
端口侦听不会终止,我再次 运行 sudo lsof -nP -i:5000 | grep LISTEN
进行测试,但它再次给了我那个结果
ControlCe 4271 sametcelikbicak 17u IPv4 0xac23fd0849ef2c59 0t0 TCP *:5000 (LISTEN)
ControlCe 4271 sametcelikbicak 18u IPv6 0xac23fd083995b411 0t0 TCP *:5000 (LISTEN)
如果我尝试 ASPNETCORE_URLS=http://*:5001
到 运行 .Net Core 应用程序它工作,我也重新启动我的 mac 但仍然给出错误,为什么 ASPNETCORE_URLS=http://*:5000
配置不起作用使用 Monterey
并且始终使用端口 5000
还有我的 dotnet 版本和 sdk-list 如下
➜ ~ dotnet --list-sdks
2.1.4 [/usr/local/share/dotnet/sdk]
2.1.402 [/usr/local/share/dotnet/sdk]
2.1.504 [/usr/local/share/dotnet/sdk]
3.1.201 [/usr/local/share/dotnet/sdk]
3.1.300 [/usr/local/share/dotnet/sdk]
5.0.102 [/usr/local/share/dotnet/sdk]
5.0.103 [/usr/local/share/dotnet/sdk]
5.0.300 [/usr/local/share/dotnet/sdk]
➜ ~ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
➜ ~ dotnet --version
5.0.300
➜ ~
感谢任何建议。
感谢 @devNull, AirPlay in the Control Center 解决方案解决了我的问题。
解决方案的基本步骤;
转到系统偏好设置 > 共享 > 取消选中 AirPlay Receiver