AlexxIT/go2rtc · error
config file disabled
Error message
config file disabled
What it means
PatchConfig persists a change to the YAML config file, but go2rtc was started without a config file path (ConfigPath == ""), e.g. running with no -config flag and no config file discovered. Since there is no file to write to, all config patching (API /api PATCH calls, stream pairing, etc.) is disabled. The library refuses the operation rather than silently discarding changes.
Solutions
- Start go2rtc with a config file: pass -config /path/to/go2rtc.yaml (or place go2rtc.yaml in the working directory) so ConfigPath is set
- If config is intentionally disabled, stop using config-patching APIs and manage configuration via startup config/env instead
- Verify ConfigPath is non-empty at runtime before calling the patching APIs
Example fix
// before exec: go2rtc (no config) // after exec: go2rtc -config /etc/go2rtc/go2rtc.yaml
Defensive patterns
Strategy: validation
Validate before calling
if app.ConfigPath == "" { return errors.New("config patching requires a config file; start with -config") } Try / catch
if err := app.PatchConfig(path, value); err != nil { if err.Error() == "config file disabled" { /* fall back to in-memory config */ } } Prevention
- Always launch go2rtc with an explicit -config path when using the PATCH/pair APIs
- Check ConfigPath before enabling config-writing UI features
- Mount a writable go2rtc.yaml in container deployments
When it happens
Trigger: Any call to PatchConfig or an API endpoint that patches config (SetValue, apiPair, apiUnpair, apiStreams, apiPreload) when the process was launched without a config file.
Common situations: Running go2rtc with environment variables only or defaults instead of a config file; calling the HTTP API (POST/PATCH to /api/streams etc.) on an instance started without -config; Docker images without a mounted go2rtc.yaml.
Related errors
- exec: rtsp module disabled
- echo: bin not in allow_paths:
- exec: bin not in allow_paths:
- expr: result is empty
- ffmpeg: unsupported params:
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/510bc58d4c91aa76.
Report an issue: GitHub.
Appendix: source
Thrown at internal/app/config.go:26
"sync"
"github.com/AlexxIT/go2rtc/pkg/creds"
"github.com/AlexxIT/go2rtc/pkg/yaml"
)
func LoadConfig(v any) {
for _, data := range configs {
if err := yaml.Unmarshal(data, v); err != nil {
Logger.Warn().Err(err).Send()
}
}
}
var configMu sync.Mutex
func PatchConfig(path []string, value any) error {
if ConfigPath == "" {
return errors.New("config file disabled")
}
configMu.Lock()
defer configMu.Unlock()
// empty config is OK
b, _ := os.ReadFile(ConfigPath)
b, err := yaml.Patch(b, path, value)
if err != nil {
return err
}
return os.WriteFile(ConfigPath, b, 0644)
}
type flagConfig []string
View on GitHub (pinned to c245815e75)