Since I’m struggling to get even simple things to work, I decided it might be a good idea to run the caddy tutorials at
Well, even the very first step is not working?
‘’’
Create a new text file named Caddyfile (no extension).
The first thing you should type is your site’s [address]
localhost
If the HTTP and HTTPS ports (80 and 443, respectively) are privileged ports on your OS, you will either need to run with elevated privileges or use a higher port. To use a higher port, just change the address to something like localhost:2015 and change the HTTP port using the http_port Caddyfile option.
Then hit enter and type what you want it to do. For this tutorial, make your Caddyfile look like this:
localhost
respond "Hello, world!"
Save that and run Caddy (since this is a training tutorial, we’ll use the --watch flag so changes to our Caddyfile are applied automatically):
caddy run --watch
And here’s the response I get:
2025/03/09 18:11:45.270 INFO using adjacent Caddyfile
2025/03/09 18:11:45.275 INFO adapted config to JSON {"adapter": "caddyfile"}
2025/03/09 18:11:45.277 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2025/03/09 18:11:45.278 INFO 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}
2025/03/09 18:11:45.278 INFO http.auto_https enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2025/03/09 18:11:45.278 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00032f900"}
2025/03/09 18:11:45.279 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2025/03/09 18:11:45.280 INFO http enabling HTTP/3 listener {"addr": ":443"}
2025/03/09 18:11:45.281 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/03/09 18:11:45.282 WARN http HTTP/2 skipped because it requires TLS {"network": "tcp", "addr": ":80"}
2025/03/09 18:11:45.282 WARN http HTTP/3 skipped because it requires TLS {"network": "tcp", "addr": ":80"}
2025/03/09 18:11:45.283 INFO http.log server running {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2025/03/09 18:11:45.283 INFO http enabling automatic TLS certificate management {"domains": ["localhost"]}
2025/03/09 18:11:45.285 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2025/03/09 18:11:45.286 INFO serving initial configuration
2025/03/09 18:11:45.287 INFO watcher watching config file for changes {"config_file": "Caddyfile"}
2025/03/09 18:11:45.335 INFO tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:/root/.local/share/caddy", "instance": "dadd446a-c4d9-42f1-b2c8-6fd3f5d712d2", "try_again": "2025/03/10 18:11:45.335", "try_again_in": 86399.999998415}
2025/03/09 18:11:45.335 INFO tls finished cleaning storage units
What am I doing wrong?
Ray