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

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"

QQ%E5%9B%BE%E7%89%8720180408150342

Something wrong here?

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?

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

What version of Caddy are you running?

cc/ @hacdias

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”.

The latest version: Caddy v0.10.12

@html Do you see anything on System Event Log?

The Event Viewer:

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

Download caddy with Event Hooks (hook.service)

Add environment first

use cmd(admin)

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

no"", no=

Use cmd(admin)

Options:

Dialog content to English:

What the …:face_with_raised_eyebrow:

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

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

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

You can get old versions here: https://github.com/mholt/caddy/releases – but you will have to build from source to plug in any plugins.

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

@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.

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

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?).

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

1 Like

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?)