caddy start command starts the Caddy process in the background and returns immediately after the server starts running or fails to run.
Usage
Description
Starts the Caddy process in the background, optionally bootstrapped with an initial config file. This command unblocks after the server starts running or fails to run, allowing you to continue using your terminal.Flags
Configuration file to load. Can be JSON or any format supported by an adapter.If not specified, Caddy will start without a config (admin API only).
Name of config adapter to apply. Required if the config file is not in JSON format.Common adapters:
caddyfile- Caddyfile formatyaml- YAML format (if adapter is installed)
Environment file(s) to load in KEY=VALUE format. Can be specified multiple times.Variables from the envfile will not overwrite existing environment variables.
Reload changed config file automatically.
Path of file to which to write the process ID.Useful for process management, monitoring, and stopping the server later.
Examples
Start with default Caddyfile
Caddyfile exists in the current directory, it will be used.
Start with a specific config
Start with PID file
Start with environment file
Start with auto-reload
Start with multiple environment files
Output
When successful, the command outputs:Exit Codes
0- Success (Caddy started successfully)1- Failed startup (Caddy failed to start)
How It Works
Thecaddy start command:
- Opens a TCP listener on 127.0.0.1 for success confirmation
- Generates random confirmation bytes
- Spawns a child process with
caddy runand the--pingbackflag - Passes the confirmation bytes to the child via stdin
- Waits for either:
- The child to connect back and echo the confirmation bytes (success)
- The child process to exit with an error (failure)
- Returns based on the outcome
caddy start only returns success when the server is actually running, not just when the process starts.
Stopping the Server
To stop a server started withcaddy start, use:
Related Commands
caddy run- Start Caddy in the foregroundcaddy stop- Stop a running Caddy instancecaddy reload- Reload the configuration