Run caddy as a windows service

1. My Caddy version (caddy version):


2. How I run Caddy:

i use nssm to set up the windows service.

a. System environment:

windows server 2016

b. Command:

start reverse-proxy -host -agree -conf c:\caddy\caddyfile -log c:\caddy\serverrun.log

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:


(theheaders) {
header_up X-Forwarded-Ssl on
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Port {server_port}
header_up X-Forwarded-Proto {scheme}
header_up X-Url-Scheme {scheme}
header_up X-Forwarded-Host {host}
} {
reverse_proxy {
import theheaders

3. The problem I’m having:

if i run the following in from cmd then caddy works amazingly.

start reverse-proxy -host -agree -email -conf c:\caddy\caddyfile -log c:\caddy\serverrun.log

but if i start the windows service created with nssm it appears that nothing is happening. i can’t get to my site and no logs are created. I’ve set the service to run under the same account that i’m using when i run this from the cmd line.

4. Error messages and/or full log output:

caddy isn’t throwing any logs, nssm stderr.log shows that the caddy server is running but doesn’t explain why it works when running from cmd prompt but not in a service.

5. What I already tried:

I’ve tried other methods of creating the service, a different caddyfile, tried using localhost:2019 and still unable to work when running as a service.

6. Links to relevant resources:

Welcome Brian –

I don’t use Windows so I don’t know much about it, but I can say that your caddy command looks like it’s still using the v1 command line arguments and flags, which won’t work.

The v2 command line is documented here: Command Line — Caddy Documentation

All other config goes into your config file.

Hopefully somebody else here knows about the Windows service stuff!

thanks Matt! I stood up an ubuntu box and installed but it didn’t like the caddyfile from above. specifically, it barked about “theheaders”. I removed that piece but then it wasn’t doing the proxy or the ssl piece. the client is working beautifully on windows, I just can’t run it as a service.

In case anyone else has this issue I found this resource and it’s all working great!!

1 Like

I don’t use Windows so I don’t know much about it

Just to let you know: The reason that I’m using Caddy, is that it does indeed run on Windows.

Companies that don’t have dedicated reverse proxies / load balancers (like Netscaler or other products) are most often running Windows only environments (in my experience).

For them, an easy to install and configure reverse proxy is essential that it can run on Windows.
(Even though it is not your favorite os. :wink:

Now, getting V2 ready is by far the first priority. But I’d think getting a stable platform for Windows is well worth the investment.

NSSM is an option. But I prefer not having too many building blocks. Keep it simple. Make ‘caddy start’ start the Windows service Caddy Server. :slight_smile:


I don’t have a “favorite OS” – I just don’t use Windows, regardless of how many companies may use it or like it. :man_shrugging: Feel free to compile a guide to set it up as a Windows service. I don’t know how, so I can’t do it.

@Brian, NSSM has a good reputation. If you (or anyone else) prefer running Caddy without installing anything extra, it is also possible to use the standard Windows Task Scheduler:

  • Create task
  • On Trigger, you change ‘On a schedule’ (at the very top), to ‘At startup’

I guess it depends on how stable V2 is, running on Windows. As I don’t think you get the same restart-on-failure capabilities with Task Scheduler. But is another option with plain Windows.


1 Like

If there’s a canonical way – or maybe two ways – to set up Caddy as a Windows service, I’ll add it to Install — Caddy Documentation. Just tell me what it is. :stuck_out_tongue:

1 Like

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