Unable to start Kestrel. System.Net.Sockets.SocketException (13): Permission denied

7/5/2020
Back to List

Problem

When running a ASP.NET Core application as a non-root user, Kestrel fails to bind to port 80 and 443.

Unable to start Kestrel. System.Net.Sockets.SocketException (13): Permission denied

Solution

To allow the app to bind to privelaged ports between 1 and 1023 run the following command, adjusting the path to the binary.

sudo setcap CAP_NET_BIND_SERVICE=+eip /path/to/binary

SuperChad
Gravatar About Sean Nelson
I like codes and stuff.

1 comments
Gravatar aid for ukraine - 6/7/2022 3:32:56 AM
Hi there, just became alert to your blog through Google, and found that it is truly informative. I'm going to watch out for brussels. I will be grateful if you continue this in future. A lot of people will be benefited from your writing. Cheers!