{"record":{"id":"dcf9607216b59f1b","repo":"fatedier/frp","slug":"login-to-the-server-failed-v-with-loginfailexit","errorCode":null,"errorMessage":"login to the server failed: %v. With loginFailExit enabled, no additional retries will be attempted","messagePattern":"login to the server failed: (.+?)\\. With loginFailExit enabled, no additional retries will be attempted","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/service.go","lineNumber":267,"sourceCode":"\t}\n\n\tif svr.webServer != nil {\n\t\twebServer := svr.webServer\n\t\tgo func() {\n\t\t\tlog.Infof(\"admin server listen on %s\", webServer.Address())\n\t\t\tif err := webServer.Run(); err != nil && !errors.Is(err, http.ErrServerClosed) {\n\t\t\t\tlog.Warnf(\"admin server exit with error: %v\", err)\n\t\t\t}\n\t\t}()\n\t}\n\n\t// first login to frps\n\tsvr.loopLoginUntilSuccess(10*time.Second, lo.FromPtr(svr.common.LoginFailExit))\n\tif svr.ctl == nil {\n\t\tcancelCause := cancelErr{}\n\t\t_ = errors.As(context.Cause(svr.ctx), &cancelCause)\n\t\tsvr.stop()\n\t\treturn fmt.Errorf(\"login to the server failed: %v. With loginFailExit enabled, no additional retries will be attempted\", cancelCause.Err)\n\t}\n\n\tgo svr.keepControllerWorking()\n\n\t<-svr.ctx.Done()\n\tsvr.stop()\n\treturn nil\n}\n\nfunc (svr *Service) keepControllerWorking() {\n\t<-svr.ctl.Done()\n\n\t// There is a situation where the login is successful but due to certain reasons,\n\t// the control immediately exits. It is necessary to limit the frequency of reconnection in this case.\n\t// The interval for the first three retries in 1 minute will be very short, and then it will increase exponentially.\n\t// The maximum interval is 20 seconds.\n\twait.BackoffUntil(func() (bool, error) {\n\t\t// loopLoginUntilSuccess is another layer of loop that will continuously attempt to","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/client/service.go#L249-L285","documentation":"Returned from Service.Run when the initial login to frps did not succeed and loginFailExit is enabled (the default). loopLoginUntilSuccess gave up (or the context was cancelled with a cancelErr), svr.ctl is nil, so frpc stops and reports the login failure reason with a note that no retries will be attempted.","triggerScenarios":"Starting frpc with loginFailExit = true against an unreachable/misauthenticated frps: wrong server address/port, TLS mismatch (transport.tls vs frps proxyProtocol/tls settings), auth.token mismatch, or firewall blocking. The context cancellation cause carries the concrete login error.","commonSituations":"First-run misconfiguration (serverAddr typo, forgot serverPort); auth method/token mismatch after enabling token auth on frps; frps behind LB terminating TLS; running frpc as a one-shot job where infinite retry is unwanted, hence loginFailExit=true.","solutions":["Read the %v portion — it contains the real login error (dial timeout, auth failure, tls error) and dictates the fix.","Verify serverAddr/serverPort and network reachability of frps (telnet/curl the port).","Align auth settings (auth.method, auth.token) and TLS settings on both frpc and frps.","If frps may start later than frpc, set loginFailExit = false so frpc retries instead of exiting."],"exampleFix":"# before (frpc.toml)\nloginFailExit = true\nserverAddr = \"10.0.0.1\"\nserverPort = 7000\n\n# after (when frps may be temporarily down)\nloginFailExit = false","handlingStrategy":"fallback","validationCode":"// Pre-flight: can we reach frps before launching frpc?\nconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:%d\", serverAddr, serverPort), 3*time.Second)\nif err != nil { return fmt.Errorf(\"frps unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"err := svr.Run(ctx)\nif err != nil && strings.Contains(err.Error(), \"login to the server failed\") {\n    // inspect embedded cause: auth vs network; fix auth.token / serverAddr, or set loginFailExit=false and let systemd restart frpc\n}","preventionTips":["Set loginFailExit=false when frpc may start before frps (e.g. docker-compose).","Pre-check connectivity and auth token before deploying.","Keep auth and TLS config in sync across frpc/frps in one repo."],"tags":["login","auth","startup","frpc","network"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}