Unexpected behavior with RELOAD as non-privileged user on Windows

1. Caddy version (caddy version):

v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=

2. How I run Caddy:

Windows task scheduler, using a local user account without administrative privileges.

a. System environment:

Windows Server 2016 Standard [Version 10.0.17763.2029]

b. Command:

D:\Server\Caddy\caddy_windows_amd64.exe reload --config "D:\Server\Caddy\Caddyfile"

c. Service/unit/compose file:

$ProcessPath = "D:\Server\Caddy"
$ProcessExe = "caddy_windows_amd64.exe"
$ProcessName = "caddy_windows_amd64"
$ProcessConfig = "Caddyfile"

try {
    $Process = Get-Process -Name $ProcessName -ErrorAction Stop
    if ($Process) {
        Start-Process -WorkingDirectory $ProcessPath -FilePath "$($ProcessPath)\$($ProcessExe)" -ArgumentList "reload --config ""$($ProcessPath)\$($ProcessConfig)""" -ErrorAction Stop
catch [Microsoft.PowerShell.Commands.ProcessCommandException] {
    try {
        Start-Process -WorkingDirectory $ProcessPath -FilePath "$($ProcessPath)\$($ProcessExe)" -ArgumentList "run --config ""$($ProcessPath)\$($ProcessConfig)""" -ErrorAction Stop
    catch {
        exit 1
catch {
    exit 1
exit 0

d. My complete Caddyfile or JSON config:

pineae.org {
	#respond "It works!"
	#respond "Reload worked!"
	respond "Reload worked again!"
	header { Strict-Transport-Security max-age=31536000; }

3. The problem I’m having:

Each time I run the above command, a new process is spawned and none of them ever exit. If I run it 10 times, there are 10 instances of Caddy running simultaneously.

4. Error messages and/or full log output:

I can find no errors in any logs.

5. What I already tried:

If I add the user account to the Administrators group, and the above command functions as expected where simultaneous process do not persist.

6. Links to relevant resources:

This is invalid syntax. You must have newlines after { and before }, otherwise Caddy parses the braces as being arguments to the header directive. Or, just omit the braces, because they’re not necessary for single-line syntax.

header Strict-Transport-Security max-age=31536000;


header {
	Strict-Transport-Security max-age=31536000;

I can’t really help you debug your script.

We’ve recently merged instructions for running Caddy as a Windows service to docs (not pushed live yet); I recommend using these instructions instead:

1 Like

Okay that’s awesome. I’ve got it running as a service now. Thank you.

  <!-- Display name of the service -->
  <name>Caddy Web Server (powered by WinSW)</name>
  <!-- Service description -->
  <description>Caddy Web Server (https://caddyserver.com/)</description>
  <log mode="roll-by-time">

Thanks for pointing out the syntax issue in my Caddyfile too. I do not believe it was causing this problem, but I’ve corrected it.

Reload appears to be working fine for me now too. This is excellent.

1 Like

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