{"record":{"id":"7bcd652dfca75dad","repo":"fatedier/frp","slug":"apply-config-failed-v","errorCode":null,"errorMessage":"apply config failed: %v","messagePattern":"apply config failed: (.+?)","errorType":"http","errorClass":"ErrApplyConfig","httpStatus":500,"severity":"error","filePath":"client/config_manager.go","lineNumber":49,"sourceCode":"\tresult, err := config.LoadClientConfigResult(m.svr.configFilePath, strict)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w: %v\", configmgmt.ErrInvalidArgument, err)\n\t}\n\n\tproxyCfgsForValidation, visitorCfgsForValidation := config.FilterClientConfigurers(\n\t\tresult.Common,\n\t\tresult.Proxies,\n\t\tresult.Visitors,\n\t)\n\tproxyCfgsForValidation = config.CompleteProxyConfigurers(proxyCfgsForValidation)\n\tvisitorCfgsForValidation = config.CompleteVisitorConfigurers(visitorCfgsForValidation)\n\n\tif _, err := validation.ValidateAllClientConfig(result.Common, proxyCfgsForValidation, visitorCfgsForValidation, m.svr.unsafeFeatures); err != nil {\n\t\treturn fmt.Errorf(\"%w: %v\", configmgmt.ErrInvalidArgument, err)\n\t}\n\n\tif err := m.svr.UpdateConfigSource(result.Common, result.Proxies, result.Visitors); err != nil {\n\t\treturn fmt.Errorf(\"%w: %v\", configmgmt.ErrApplyConfig, err)\n\t}\n\n\tlog.Infof(\"success reload conf\")\n\treturn nil\n}\n\nfunc (m *serviceConfigManager) ReadConfigFile() (string, error) {\n\tif m.svr.configFilePath == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%w: frpc has no config file path\", configmgmt.ErrInvalidArgument)\n\t}\n\n\tcontent, err := os.ReadFile(m.svr.configFilePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: %v\", configmgmt.ErrInvalidArgument, err)\n\t}\n\treturn string(content), nil\n}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/client/config_manager.go#L31-L67","documentation":"Returned by serviceConfigManager.ReloadFromFile when svr.UpdateConfigSource fails while applying the freshly loaded and validated config to the running frpc service — i.e. parsing and validation succeeded but the live swap-in failed. It wraps configmgmt.ErrApplyConfig to distinguish it from ErrInvalidArgument cases.","triggerScenarios":"Reloading a config whose proxies/visitors cannot be brought up at runtime (e.g. binding a local port already in use on the frpc host, or a listener type the running service cannot restart); internal state-transition failures inside the client service during hot reload.","commonSituations":"Hot-reload after editing bindAddr/bindPort of visitors to a port occupied by another process on the frpc machine; reloading while the previous config's proxies are mid-teardown; resource limits preventing new listeners.","solutions":["Check the %v detail and frpc logs for which proxy/visitor failed to apply; fix that item (free the local port, correct bindAddr)","If reload state is wedged, do a full restart of frpc with the new config instead of hot reload","Verify local ports for visitors/proxies are free on the frpc host (ss -ltnp)","Keep hot reloads to config-only changes; restart for changes that rebind listeners"],"exampleFix":"# before — visitor bindPort 6000 already used locally\n[[visitors]]\nname = \"stcp-v\"\ntype = \"stcp\"\nbindAddr = \"127.0.0.1\"\nbindPort = 6000\n\n# after\nbindPort = 6100","handlingStrategy":"fallback","validationCode":"// Pre-check local bind ports for visitors/proxies before reload\nfor _, v := range visitorCfgs {\n    ln, err := net.Listen(\"tcp\", net.JoinHostPort(v.BindAddr, strconv.Itoa(v.BindPort)))\n    if err != nil {\n        return fmt.Errorf(\"visitor %s cannot bind %s:%d: %v\", v.Name, v.BindAddr, v.BindPort, err)\n    }\n    ln.Close()\n}","typeGuard":"func isApplyConfig(err error) bool {\n    return errors.Is(err, configmgmt.ErrApplyConfig)\n}","tryCatchPattern":"if err := configManager.ReloadFromFile(true); err != nil {\n    if errors.Is(err, configmgmt.ErrApplyConfig) {\n        // config is valid but could not be applied live: fall back to a full frpc restart with the new file\n    }\n}","preventionTips":["Free or change local ports that listeners will bind before hot-reload","For changes that rebind listeners, prefer a supervised restart over hot reload"],"tags":["frp","frpc","go","config","reload","apply"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}