-1

我升级macOS Big SurmacOS 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
➜  ~

感谢您的任何建议。

4

1 回答 1

0

感谢@devNull控制中心解决方案中的 AirPlay 解决了我的问题。

解决方案的基本步骤;

转到系统偏好设置>共享>取消选中AirPlay Receiver

于 2021-10-27T17:00:45.157 回答