Caddy foundations
Run disposable servers
Use Caddy’s command shortcuts to serve one response and one directory before creating persistent configuration.
10 minute lesson
You don’t need a configuration file to try Caddy. The CLI includes shortcuts that start a working server from a single command. They’re perfect for quick experiments, for checking whether a port works, or for sharing a folder on your machine for five minutes.
caddy respond starts a server that returns a fixed response:
caddy respond --listen 127.0.0.1:8080 --body 'hello from Caddy'
In another terminal, prove it works:
curl http://127.0.0.1:8080/
You get hello from Caddy back. That one line proved the binary runs, the port is free, and HTTP flows end to end. When you’re debugging a networking problem, a server this dumb is exactly what you want, because nothing else can go wrong.
Stop it with Ctrl-C, then try the second shortcut. caddy file-server serves a directory:
mkdir -p public && echo '<h1>Hi</h1>' > public/index.html
caddy file-server --listen 127.0.0.1:8080 --root ./public --browse
Request http://127.0.0.1:8080/ and you get your HTML back. The --browse flag adds a directory listing for folders that have no index file.
Notice that both commands listen on 127.0.0.1. That keeps the server private to your machine. Bind to :8080 instead and every device on your network can reach it — and a directory can contain .env files, source code, or anything else you forgot was in there. My advice is to start on loopback and widen access deliberately, never by accident.
A failure you’ll hit sooner or later: the port is taken. Caddy exits immediately with bind: address already in use. Find the culprit with lsof -i :8080 on macOS or ss -lntp on Linux, then stop it or pick another port.
Lesson completed