cloudflare/cloudflared · warning
Error starting tracing
Error message
Error starting tracing
What it means
StartServer optionally enables Go runtime execution tracing when the --trace-output flag points at a file; if trace.Start(tmpTraceFile) fails the error is wrapped as 'Error starting tracing'. trace.Start fails mainly when tracing is already active in this process or the runtime build doesn't support it, so cloudflared aborts startup rather than running without the requested trace.
Source
Thrown at cmd/cloudflared/tunnel/cmd.go:367
traceOutputFilepath := c.String(cfdflags.TraceOutput)
//nolint:gosec // File path is safe because it is explicitly provided by the user via the --trace-output flag
if err := os.Rename(tmpTraceFile.Name(), traceOutputFilepath); err != nil {
traceLog.
Err(err).
Str(LogFieldTraceOutputFilepath, traceOutputFilepath).
Msg("Failed to rename temporary trace output file")
} else {
//nolint:gosec // File path is safe, since it is created by os.CreateTemp
err := os.Remove(tmpTraceFile.Name())
if err != nil {
traceLog.Err(err).Msg("Failed to remove the temporary trace file")
}
}
}()
if err := trace.Start(tmpTraceFile); err != nil {
traceLog.Err(err).Msg("Failed to start trace")
return errors.Wrap(err, "Error starting tracing")
}
defer trace.Stop()
}
info.Log(log)
logClientOptions(c, log)
// this context drives the server, when it's canceled tunnel and all other components (origins, dns, etc...) should stop
ctx, cancel := context.WithCancel(c.Context)
defer cancel()
go waitForSignal(graceShutdownC, log)
connectedSignal := signal.New(make(chan struct{}))
go notifySystemd(connectedSignal)
if c.IsSet("pidfile") {
go writePidFile(connectedSignal, c.String("pidfile"), log)
}View on GitHub (pinned to 2253eeeb25)
Solutions
- Remove the --trace-output flag if you don't need an execution trace — this code path only runs when it is set.
- Ensure only one tracing session runs in the process; don't nest cloudflared inside a tool that enabled runtime tracing.
- Retry without other tracing activators (e.g. GODEBUG settings) competing for the tracer.
- If it persists, check the wrapped inner error for the runtime's specific reason and consider upgrading Go/cloudflared.
Example fix
// before cloudflared tunnel run --name mytunnel --trace-output /tmp/trace.out // after (tracing disabled) cloudflared tunnel run --name mytunnel
Defensive patterns
Strategy: try-catch
Validate before calling
// only pass the flag when tracing is truly needed
if traceRequested && tracingAlreadyActive() { flags = remove(flags, "--trace-output") } Try / catch
if err := startServer(); err != nil && strings.Contains(err.Error(), "Error starting tracing") {
log.Warnf("tracing unavailable (%v); retrying without --trace-output", err)
err = startServerWithoutTrace()
} Prevention
- Only set --trace-output when you actually need an execution trace
- Avoid nesting cloudflared in wrappers that enable Go runtime tracing themselves
- Retry without the flag — it is purely a diagnostics feature
- Keep cloudflared/Go toolchain updated to avoid runtime trace edge cases
When it happens
Trigger: Running cloudflared with --trace-output=<file> when the Go runtime rejects trace.Start: execution tracing already enabled for the process, or trace.Start returning an error for the opened file (runtime/trace unsupported state). Note the file open itself is handled earlier — this error is specifically from trace.Start.
Common situations: Nested cloudflared invocations or wrappers that already started tracing; supplying --trace-output in an environment where runtime tracing was already activated; rare Go runtime/version edge cases around trace startup.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- ErrManagedLogNotFound
- ErrLogConfigurationIsInvalid
- ErrInsufficientLines
- ErrInsuficientFields
- ErrKeyNotFound
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/58cf944acb7bc8e6.
Report an issue: GitHub.