Home > Mobile >  Unable to start Kestrel on macOS Monterey
Unable to start Kestrel on macOS Monterey

Time:10-30

I upgrade my macOS Big Sur to macOS Monterey then I try to run my .Net Core app with ASPNETCORE_URLS=http://*:5000 config it gives me error as below

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

when I try find who listen the port 5000 with codes as below

sudo lsof -nP -i:5000 | grep LISTEN

results are;

ControlCe 2874 sametcelikbicak   17u  IPv4 0xac23fd083a725c89      0t0  TCP *:5000 (LISTEN)
ControlCe 2874 sametcelikbicak   18u  IPv6 0xac23fd082e8a6671      0t0  TCP *:5000 (LISTEN)

then I try to kill that listen with kill command as below

kill -9 2874

that port listen does not kill, I run sudo lsof -nP -i:5000 | grep LISTEN again to test it but it gave me that result again

ControlCe 4271 sametcelikbicak   17u  IPv4 0xac23fd0849ef2c59      0t0  TCP *:5000 (LISTEN)
ControlCe 4271 sametcelikbicak   18u  IPv6 0xac23fd083995b411      0t0  TCP *:5000 (LISTEN)

if I try ASPNETCORE_URLS=http://*:5001 to run .Net Core app it works, also I restart my mac but still gives error, why ASPNETCORE_URLS=http://*:5000 config does not work with Monterey and who always use the port 5000

Also my dotnet version and sdk-list as below

➜  ~ 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
➜  ~

Thanks for any advice.

CodePudding user response:

Thanks to @devNull, AirPlay in the Control Center solutions fixed my problem.

Basic steps of the solutions;

Goto to System Preferences > Sharing > Uncheck AirPlay Receiver

  • Related