cloudflare / cloudflare/cloudflared
🐛 Setting grace period to anything makes `cloudflared` exit immediately
- Dominant language
- Go
- Stars
- 15.6k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I haven't tested this with a local configuration.
Setting the grace period as defined in the [Tunnel run parameters](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/configure-tunnels/cloudflared-parameters/run-parameters/#grace-period) section in the docs using an environment variable makes `cloudflared` exit immediately with no output and code 0.
Setting it with `cloudflared tunnel --grace-period 10 run` prints `Incorrect Usage. invalid value "10" for flag -grace-period: parse error`, exiting with code 0.
While I haven't tested with a local configuration, and even though the documentation *suggests* it only works with one (usage places `` after the parameter in the example), it doesn't explicitly state so like it does with [`origincert`](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/configure-tunnels/cloudflared-parameters/run-parameters/#origincert), for example. (so I assume this isn't a documentation error, and grace period is supposed to be supported with a remote managed configuration. I don't see why not?)
**To Reproduce**
Environment variable:
1. Run:
```bash
TUNNEL_GRACE_PERIOD=10 TUNNEL_TOKEN=TOKEN /opt/cloudflared/cloudflared-linux-amd64 tunnel run
```
2. It exits immediately. No error printed.
In fact, if you omit the token and just run:
```bash
TUNNEL_GRACE_PERIOD=10 /opt/cloudflared/cloudflared-linux-amd64 tunnel run
```
The help message `"cloudflared tunnel run" requires the ID or name of the tunnel to run as the last command line argument or in the configuration file.` doesn't appear at all. You can actually just run the path to the binary without any parameters, and the simple presence of that environment variable causes `cloudflared` to just exit without doing anything.
Command line parameter:
1. Run:
```bash
/opt/cloudflared/cloudflared-linux-amd64 tunnel --grace-period 10 run
```
2. Usage message prints with `Incorrect Usage. invalid value "10" for flag -grace-period: parse error`.
**Expected behavior**
If the issue is because it is a remote managed configuration, `cloudflared` would at least state that a grace period isn't supported with remote configurations. If not, it should just work.
**Environment and versions**
- OS: Unprivileged Debian 13 LXC on Proxmox 9
- Architecture: AMD64
- Version: 2026.2.0, running from the binary available in [Releases](https://github.com/cloudflare/cloudflared/releases/tag/2026.2.0).
**Logs and errors**
See above.
**Additional context**
Tested both as root, and as a dedicated `cloudflared` user and group, both from a shell, and from a `systemd` service. The `systemd` service exits with the message: `cloudflared.service: Failed with result 'protocol'.`
Contributor guide
Assessment
This issue has not been assessed yet.