cloudflared
cloudflared copied to clipboard
Argo Tunnel Agent service won't start on Windows Server 2019
I've created a config.yml file along with credentials file in C:\Windows\System32\config\systemprofile\.cloudflared
I'm using Windows 2019 Server.
If I use psexec to launch a cmd prompt as the system account and invoke cloudflared tunnel run
then the tunnel works as expected.
If I use service manager to start the service it immediately stops. There is no indication as to what the error is in any of the Windows event viewer logs.
The exact same configuration files and cloudflared.exe on Windows Server 2012 works correctly.
Is there any way to debug the errors caused by running the process as a service?
Pull up regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
and find your Argo tunnel agent service (mine is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cloudflared
). Check the ImagePath string and look at the arguments there. For example, mine is,
C:\Users\parker.stephens\Documents\cloudflared\cloudflared-windows-amd64.exe tunnel --config C:\\Users\\parker.stephens\\.cloudflared\\config.yml run
.
Change your config path and executable path to the one that you created and see if it runs then.
@parker-stephens thanks for the suggestion, but it hasn't made any difference - service still stops as soon as it starts. Didn't have to do this on Windows 2012 and it just ran with the config file being in the profile path. It would be useful if I could enable some logging to try and see what is going on but I can't find anything. As I say, running the command manually it starts up fine and it runs on the older OS.
+1 on Server 2022
PS C:\Cloudflared\bin> Start-Service Cloudflared -Verbose
VERBOSE: Performing the operation "Start-Service" on target "Cloudflare Tunnel
agent (Cloudflared)".
Start-Service : Failed to start service 'Cloudflare Tunnel agent
(Cloudflared)'.
At line:1 char:1
+ Start-Service Cloudflared -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceControl
ler:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands
.StartServiceCommand
PS C:\Cloudflared\bin> Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\Cloudflared\ImagePath\
Hive: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cloudflared
Name Property
---- --------
ImagePath (default) : C:\Cloudflared\bin\cloudflared.exe
--config=C:\Windows\System32\con
fig\systemprofile\.cloudflared\config.yml
tunnel run
PS C:\Cloudflared\bin> Get-EventLog Application -Newest 1 -Source cloudflared | Format-List
Index : 6905
EntryType : Information
InstanceId : 1
Message : Cloudflared service arguments:
[C:\Cloudflared\bin\cloudflared.exe]
Category : (0)
CategoryNumber : 0
ReplacementStrings : {Cloudflared service arguments:
[C:\Cloudflared\bin\cloudflared.exe]}
Source : Cloudflared
TimeGenerated : 11/19/2021 6:17:25 PM
TimeWritten : 11/19/2021 6:17:25 PM
UserName :
PS C:\Cloudflared\bin>
The command does work on its own.
PS C:\Cloudflared\bin> C:\Cloudflared\bin\cloudflared.exe --config=C:\Windows\System32\config\systemprofile\.cloudflared\config.yml tunnel run
2021-11-19T18:18:44Z INF Starting tunnel tunnelID=
[...]
Don't run the service as "Local System" - run it as a service account that has access to the config files & .exe files..