Caddy on Pi, site on Mac mini -- help?

1. Caddy version (caddy version):


2. How I run Caddy:

I had caddy running perfectly on a raspberry pi on my local network. I moved the node app that was serving up my website to my mac mini, because the Pi was struggling. I want to run caddy on the mac (mac-mini.local /

a. System environment:

MacOS Monterey

b. Command:

I have tried both caddy start and brew services start caddy. Both give me errors. I’ve resorted to using brew services restart caddy

I have also tried on the mac, a simple caddy reverse-proxy --from --to localhost:30000

c. Service/unit/compose file:

not sure I have anything relevant here... But not really sure I don’t, either. 

d. My complete Caddyfile or JSON config:

this is located in /etc/Caddyfile, /etc/caddy/Caddyfile, and /Users/myusername/Library/Application\ Support/Caddy/.

# This replaces the existing content in /etc/caddy/Caddyfile

	default_sni <-- [Mac's IP address, not the pi, where caddy is running]
} {
	tls internal
	reverse_proxy localhost:30000
	encode zstd gzip
} {
	reverse_proxy localhost:30000
	encode zstd gzip

# Refer to the Caddy docs for more information:

# This replaces the existing content in /etc/caddy/Caddyfile


3. The problem I’m having:

neither ports 80 nor 443 are open. I do a port scan of the domain,, and port 30000 (the app) is open, but 80 and 443 remain resolutely closed. I am not sure what I’m doing wrong.

4. Error messages and/or full log output:

When running brew services start caddy:

Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/myusername/Library/LaunchAgents/homebrew.mxcl.caddy.plist` exited with 5.

when running sudo brew services start caddy:

Warning: Taking root:admin ownership of some caddy paths:
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
Warning: caddy must be run as non-root to start at user login!
==> Successfully started `caddy` (label: homebrew.mxcl.caddy)

when trying sudo caddy stop:

2022/01/11 17:20:37.154	WARN	failed using API to stop instance	{"error": "performing request: Post \"http://localhost:2019/stop\": dial tcp [::1]:2019: connect: connection refused"}
stop: performing request: Post "http://localhost:2019/stop": dial tcp [::1]:2019: connect: connection refused

when trying curl https://localhost:2019/stop

curl: (7) Failed to connect to localhost port 2019 after 2 ms: Connection refused

After I run caddy reverse-proxy --from --to localhost:30000, I get the following output:

2022/01/11 17:49:23.444	WARN	admin	admin endpoint disabled
2022/01/11 17:49:23.445	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0x140002fc000"}
2022/01/11 17:49:23.445	INFO	http	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "proxy", "https_port": 443}
2022/01/11 17:49:23.445	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "proxy"}
2022/01/11 17:49:23.445	INFO	tls	cleaning storage unit	{"description": "FileStorage:/Users/chrisallbritton/Library/Application Support/Caddy"}
2022/01/11 17:49:23.445	INFO	tls.cache.maintenance	stopped background certificate maintenance	{"cache": "0x140002fc000"}
reverse-proxy: loading new config: http app module: start: tcp: listening on :443: listen tcp :443: bind: address already in use

Ports 80 and 443 are now open, but I"m still not able to connect to the service running on port 30000.

Finally: when I use caddy run and I try to hit my cellular network, I get the following log:

2022/01/11 18:36:26.549	ERROR	http.log.error	dial tcp: lookup locahost on no such host	{"request": {"remote_addr": "", "proto": "HTTP/2.0", "method": "GET", "host": "", "uri": "/", "headers": {"Cookie": ["session=796be94fbf715ee05b757a8d"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"], "User-Agent": ["Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1"], "Accept-Language": ["en-US,en;q=0.9"], "Accept-Encoding": ["gzip, deflate, br"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": ""}}, "duration": 0.077580458, "status": 502, "err_id": "hmjakk0vw", "err_trace": "reverseproxy.statusError (reverseproxy.go:886)"}

5. What I already tried:

I have installed it on the mac using brew install caddy. Then I created the above Caddyfile in /etc/Caddyfile and elsewhere just to be safe. Then I ran brew services start caddy and got the first error above. I tried starting it as sudo, and got the second error above. Then I couldn’t stop it and got the third error above. and the other errors as mentioned.

I am genuinely at a loss here. I’m just not sure what I’m doing wrong. I suspect it’s something with the Caddyfile, but don’t know why it worked on the pi, but won’t on the mac, and doesn’t work now.

6. Links to relevant resources:

The plist file might be corrupted. Run:

cat /usr/local/opt/caddy/homebrew.mxcl.caddy.plist

It should have something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
1 Like