Caddy Unable to start as a service on Window server 2008 R2

(熊宝) #1

Windows could not start the Caddy on ISERVER. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 1.

It won’t start as a service, and fails with this in the Event Viewer:

The Caddy service terminated with service-specific error Incorrect function.

When installing the service I am using the following:

C:\caddy>caddy.exe -service install -conf="C:\Caddy\Caddyfile" -log="C:\Caddy\ServerRun.log"

I can start it using the caddyfile by command line:

C:\caddy>caddy.exe -conf="C:\Caddy\Caddyfile" -log="C:\Caddy\ServerRun.log"

If I install it as a service but do not specify a caddyfile, it runs fine but uses the default config (localhost:2015) as you’d expect.
Fill in the Start Parameters is same parameters, This service can run, but only startup from my manual.
-conf="C:\Caddy\Caddyfile" -log="C:\Caddy\ServerRun.log"


Something wrong here?

(Matthew Fay) #2

Nothing stands out as “wrong” to me, but I don’t run Caddy on Windows myself, so perhaps someone who does could spot something.

Is there anything in the log file at C:\Caddy\ServerRun.log?

(熊宝) #3

Nothing in the log, Because this service is not started.

(Toby Allen) #4

What version of Caddy are you running?

cc/ @hacdias

(Arcane Brain) #5

This might be the same issue someone else was having getting Caddy running as a service in Windows with nssm; where you need to run it as a specific user and not as the default “Local System Account”.

(熊宝) #6

The latest version: Caddy v0.10.12

(Henrique Dias) #7

@html Do you see anything on System Event Log?

(熊宝) #8

The Event Viewer:

The Caddy service terminated with service-specific error Incorrect function.

(xincun) #9

Download caddy with Event Hooks (hook.service)

Add environment first

use cmd(admin)

>caddy.exe -service install -conf C:\Caddy\Caddyfile

no"", no=

(熊宝) #10

Use cmd(admin)


Dialog content to English:

What the …:face_with_raised_eyebrow:

(熊宝) #11

I think, I need to trying an old Caddy version. How to download an old version?

(xincun) #12

I think this is a problem caused by no permission in the root directory of drive c.
Try to install in the desktop folder.

(熊宝) #13

The first time, I install it in the drive D:
I moved to the drive C when it failed to start.

(Matt Holt) #14

You can get old versions here: – but you will have to build from source to plug in any plugins.

(Paul Hodges) #15

You haven’t said yet what user account you are using to start the service; this is likely to be crucial.

(Toby Allen) #16

@hacdias Is it possible that this is to do with not having -agree in the command line options. Due to the change in end point for acme I think caddy will fail without this in install request for service.

(Matt Holt) #17

Caddy process log output (-log) would be very good to have.

(Matthew Fay) #18

Yeah, it would be very good. “service-specific error code 1” screams exit with errors to me, which means Caddy did start but ran into a problem (and the logs almost always explain what that problem is).

I can’t help but wonder if, as theorized in a few other places, the service account doesn’t have access to the files (can’t read the Caddyfile and exits, perhaps, and can’t write to the log file?).

(Paul Hodges) #19

Some of the built-in Windows accounts do not have access to networking - this is the direction my mind is going.

(Matthew Fay) #20

It’s a good thought, but even when Caddy has no networking permissions, it still writes to the process log. The fact that log has no content is what I don’t get in that situation. (Unless it has no networking OR file permissions?)