我升级macOS Big Sur
到macOS Monterey
然后我尝试使用ASPNETCORE_URLS=http://*:5000
配置运行我的 .Net Core 应用程序,它给了我如下错误
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 命令杀死那个监听
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
➜ ~
感谢您的任何建议。