An attempt was made to access a socket in a way forbidden by its access permissions

1. The problem I’m having:

I can’t start up Caddy because of the following error:
Error: loading initial config: loading new config: http app module: start: listening on :80: listen tcp :80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

I have nothing on port 80. It worked perfectly before, but it just stopped working now and I don’t know why, I haven’t changed anything.

2. Error messages and/or full log output:

2023/05/30 23:43:25.939 ←[34mINFO←[0m   using provided configuration    {"config_file": "C:\\Caddyfile", "config_adapter": ""}
2023/05/30 23:43:25.941 ←[33mWARN←[0m   Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "C:\\Caddyfile", "line": 30}
2023/05/30 23:43:25.957 ←[34mINFO←[0m   admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/05/30 23:43:25.957 ←[34mINFO←[0m   tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc00051a3f0"}
2023/05/30 23:43:25.957 ←[34mINFO←[0m   http    server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2023/05/30 23:43:25.958 ←[34mINFO←[0m   http    enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2023/05/30 23:43:25.959 ←[34mINFO←[0m   http    enabling HTTP/3 listener        {"addr": ":443"}
2023/05/30 23:43:25.959 ←[34mINFO←[0m   http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/05/30 23:43:25.960 ←[34mINFO←[0m   tls.cache.maintenance   stopped background certificate maintenance      {"cache": "0xc00051a3f0"}
Error: loading initial config: loading new config: http app module: start: listening on :80: listen tcp :80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

Download from Caddy website, run with .bat file on startup

a. System environment:

Windows 10 22H2 (19045.2965) x64

b. Command:

C:\caddy_windows_amd64_custom.exe run --config C:\Caddyfile

d. My complete Caddy config:

invite.thepwrtank18.me {
	reverse_proxy 192.168.1.112:2086
	tls {
		dns cloudflare [censored]
	}
}

jellyfin.thepwrtank18.me {
	reverse_proxy 192.168.1.112:8096
	tls {
		dns cloudflare [censored]
	}
}

legacy-jellyfin.thepwrtank18.me {
	reverse_proxy 192.168.1.112:5678
	tls {
		dns cloudflare [censored]
	}
}

public.thepwrtank18.me {
	header Cache-Control "no-store"
	file_server {
		root "E:\funny"
	}
	tls {
		dns cloudflare [censored]
	}
}

Caddy uses port 80 for HTTP, for solving the ACME HTTP challenge and for HTTP->HTTPS redirects.

I can’t really say why Windows is preventing you from binding to that port, but essentially it’s a problem with Windows.

I managed to find a workaround by disabling HTTP → HTTPS redirects by adding this to my Caddyfile:

{
	auto_https disable_redirects
}

I then let Cloudflare handle the upgrades for me.

This is in no way a permanent solution, especially for people who don’t use Cloudflare or another DNS service that lets you auto-upgrade to HTTPS.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.