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


(熊宝) #21

Uh, I have tried Caddyfile content just “localhost:8080”, it strated. Edit to “example.com {…}” it not start.


(Paul Hodges) #22

Example.com will not resolve to your IP address, so Caddy will be unable to get a certificate. This will, however, be recorded in Caddy’s log - are you sure you’re looking in the right place for the log?


(熊宝) #23

This “example.com” just example. actually using resolve to my host domain. This problem maybe Caddy has no networking permissions.
But I still have no resolution.


(Toby Allen) #24

Maybe these questions have already been asked, but here goes

  1. Can you start caddy not running as a service eg from cmd line?
  2. Ensure the service is installed with all the following cmd line args
    • ‘-agree’
    • ‘-log c:\afile.log’
    • '-conf “c:\mycaddyfile.caddyfile”

If any of these are missing you cannot debug the issue.


(熊宝) #25

@matt @hacdias @tobya

Hi, all.
I testing 2 version Caddy(10.10&10.12) on the Windows server 2003.
The results follows:

Caddy 0.10.10

  • Can start using “Caddy -conf /path/to/caddyfile -log /path/to/log.log” from cmd line
  • Can create a service and start using “Caddy -service install -conf /path/to/caddyfile -log /path/to/log.log”
  • Can’t start from cmd line and windows service using “Caddy -service install -agree -conf /path/to/caddyfile -log /path/to/log.log”

Caddy 0.10.12

  • Can start using “Caddy -conf /path/to/caddyfile -log /path/to/log.log” from cmd line
  • Can create a service using “Caddy -service install -conf /path/to/caddyfile -log /path/to/log.log”, But can’t start service.
  • Can’t start from cmd line and windows service using “Caddy -service install -agree -conf /path/to/caddyfile -log /path/to/log.log”

And I’ve recorded a video for my testing.

May be Caddy’s(new versions) bug? or hook.server plugin bug?
If anyone would like to try, I can provide my Windows server.


(xincun) #26

This is my problem:
https://caddy.community/t/nextcloud-php-errors/3653/3?u=xincun
I found caddy unable to start php-cgi.exe. Inspired by the upper floors, I testing 2 version the same (10.10&10.12) on win7x64.

caddy10.10 and php7.2.4:
When caddy starts, php-cgi.exe starts at the same time. Everything is OK.

caddy10.12 and php7.2.4:
When caddy starts, php-cgi.exe does not running.

The same environment, the same config.

@matt, @Whitestrake


(Matt Holt) #27

What is your Caddyfile, exactly?


(xincun) #28

https://caddy.community/t/nextcloud-php-errors/3653/3?u=xincun

Plz testing. From examples.


(Matt Holt) #29

What is your full, unedited, unredacted Caddyfile?


(xincun) #30

https://caddy.community/t/nextcloud-php-errors/3653?u=xincun
As I said in my post, this caddyfile successfully started php once and then it never started successfully.
With the help of Whitestrake, the original problem should be the folder permissions issues instead of starting PHP issues.


(xincun) #31

caddy10.14 does not pull up php-cgi.exe.


(Henrique Dias) #32

Oh, it seems to be related to this issue. It will be solved asap. :slight_smile:


(Henrique Dias) #33

@html we just updated hook.service. Could you try downloading it again?


(熊宝) #34

Wow, This problem has been solved. Is awesome. :yum:
Thank you, Hacdias!


(xincun) #35

Did you reproduce this problem? How to solve caddy not being able to wake up php-cgi.


(Toby Allen) #36

There is currently an issue with the service plugin and caddy. The service plugin prevents any on startup commands from running.

@hacdias may have updated the plugin by now, so if you download caddy with plugins again it may work,


(acemoo) #37

I would like to inform I got this error on windows 10.
No log file would be generated.
The error in the System Event log was “The Caddy service terminated with the following service-specific error:
Incorrect function.”
What helped for me was changing this
caddy -service install -conf C:\caddy\Caddyfile -log C:\caddy\caddy.log
to this
caddy -service install -conf C:\caddy\Caddyfile -log C:\caddy\caddy.log -agree -email email@example.com

Both -agree and -email seem to be needed.