An attempt was made to access a socket in a way forbidden by its access permissions. error showing when attempting to start Caddy

1. The problem I’m having:

I’m trying to run a reverse proxy thru DuckDNS to have my Jellyfin server remotely accessible.

I have downloaded Caddy and made a Caddyfile, and ran Caddy thru the Windows Powershell, as well as thru a .bat file but keep getting the error message “An attempt was made to access a socket in a way forbidden by its access permissions.”

Ports 443 and 80 are allowed in Windows Firewall and Port-Forwarded on my router.

2. Error messages and/or full log output:

2024/06/18 03:34:59.859 ←[34mINFO←[0m   using adjacent Caddyfile
2024/06/18 03:34:59.861 ←[34mINFO←[0m   adapted config to JSON  {"adapter": "caddyfile"}
2024/06/18 03:34:59.861 ←[33mWARN←[0m   Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 5}
2024/06/18 03:34:59.868 ←[34mINFO←[0m   admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/06/18 03:34:59.868 ←[34mINFO←[0m   tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc000512800"}
2024/06/18 03:34:59.868 ←[34mINFO←[0m   http.auto_https 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}
2024/06/18 03:34:59.869 ←[34mINFO←[0m   http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2024/06/18 03:34:59.869 ←[35mDEBUG←[0m  http.auto_https adjusted config {"tls": {"automation":{"policies":[{}]}}, "http": {"servers":{"remaining_auto_https_redirects":{"listen":[":80"],"routes":[{},{}]},"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8096"}]}]}]}],"terminal":true}],"tls_connection_policies":[{}],"automatic_https":{}}}}}
2024/06/18 03:34:59.869 ←[33mWARN←[0m   tls     unable to get instance ID; storage clean stamps will be incomplete
        {"error": "invalid UUID length: 0"}
2024/06/18 03:34:59.870 ←[34mINFO←[0m   tls.cache.maintenance   stopped background certificate maintenance      {"cache": "0xc000512800"}
Error: loading initial config: loading new config: http app module: start: listening on :443: listen tcp :443: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

This will sometimes change from port TCP:443 to TCP:80.

3. Caddy version:

v2.8.4

4. How I installed and ran Caddy:

From Releases · caddyserver/caddy · GitHub, selected the caddy_2.8.4_windows_amd64.zip release, extracted the .ZIP file to desktop, made the Caddyfile, and ran Caddy from Powershell.

PS C:\Users\Administrator> cd C:\Users\Administrator\Desktop\caddy\
PS C:\Users\Administrator\Desktop\caddy> .\caddy run

I even tried making a .bat an running from there.

cd C:\Users\Administrator\Desktop\caddy
caddy run
pause

a. System environment:

Microsoft Windows Server 2022
Version 21H2 (OS Build 20348.2527)
x64 bit

b. Command:

Powershell

PS C:\Users\Administrator> cd C:\Users\Administrator\Desktop\caddy\
PS C:\Users\Administrator\Desktop\caddy> .\caddy run

.bat File

cd C:\Users\Administrator\Desktop\caddy
caddy run
pause

c. Service/unit/compose file:

N/A

d. My complete Caddy config:

jellyfin.lunmar.duckdns.org {
	reverse_proxy localhost:8096
}

I have also tried adding

{
	auto_https disable_redirects
}

from a Reddit search for the solution to the top of the Caddyfile which doesn’t work.

5. Links to relevant resources:

Used this guide to set-up:

https://www.reddit.com/r/jellyfin/s/PLQ5kLzUah

Sample Caddyfile:
https://pastebin.com/raw/9MCkLFyX

This means either you already have something running using port 443 (Apache? Nginx? another Caddy instance?), or your user doesn’t have permission to bind to that port (not running as an administrator?)

You should run Caddy as a Windows service. There’s a few ways to set that up. Keep Caddy Running — Caddy Documentation

1 Like

I have ran Caddy as a Windows Service, as link in your tutorial.

Starting the service through services.msc produces this result.

image

I don’t know if something is running on that port or how I could check.

And I’m using the default Administrator account that comes with Windows Server (has Admin perms).

:man_shrugging:

Windows is not my area of expertise. Clearly something in Windows isn’t allowing you to bind to that port. You’ll need to dig deeper. Check your firewall rules, check to make sure nothing else is running which might be using that port.

1 Like

I figured it out about an hour ago.

Seems another web server was running.

Caddy works fine now.

Thanks

1 Like

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