Starting Caddy as windows service (sc.exe) hangs, but still works

1. The problem I’m having:

I set up caddy as a service in windows using the following command (powershell):

sc.exe create caddy start= auto binPath= "C:\ProgramData\chocolatey\bin\caddy.exe run --config C:/Caddyfile".

When I run sc.exe start caddy the terminal is hung and in the “Services” app in windows, the Status shows as “Starting”.

The server seems to be working, I can get the expected response from the server when it is called, and no longer get a response after I run caddy stop.

It’s just hung in the “Starting” status and when I use ctrl+C in the powershell terminal, it is no longer hung, but the service then has a status of “Stopped”, but the caddy server still works. I still have to call caddy stop to stop the server.

When I call sc.exe stop caddy after ctrl+C, it prints an error saying the service has not been started, but the caddy server is still listening.

2. Error messages and/or full log output:

I eventually get a Windows error from the Services app saying the following when trying to start the service using the GUI:

Windows could not start the caddy service on Local Computer.

Error 1053: The service did not respond to the start of control request in a timely fashion.

The Services app shows a loading bars for a while before this.

3. Caddy version:


4. How I installed and ran Caddy:

choco install caddy
sc.exe start caddy

a. System environment:

Microsoft Windows Server 2022 Standard, x64

b. Command:

Given in section 1.

c. Service/unit/compose file:


d. My complete Caddy config:

Not at liberty to share, but using auto_https off and tls cert.pem key.pem

5. Links to relevant resources:

I found my issue, I was pointing to the wrong exe. I needed to point to the chocolatey lib directory instead of the bin directory.

The exe in the bin directory just points to the one in the lib directory.