{"record":{"id":"f1c4bd3c02fefc3d","repo":"alibaba/nacos","slug":"failed-to-req-api-after-all-servers-tried","errorCode":null,"errorMessage":"failed to req API:{} after all servers({}) tried: {}","messagePattern":"failed to req API:(.+?) after all servers\\((.+?)\\) tried: (.+?)","errorType":"exception","errorClass":"NacosException","httpStatus":null,"severity":"critical","filePath":"client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java","lineNumber":422,"sourceCode":"            for (int i = 0; i < servers.size(); i++) {\n                String server = servers.get(index);\n                try {\n                    return callServer(api, params, body, server, method);\n                } catch (NacosException e) {\n                    exception = e;\n                    if (NAMING_LOGGER.isDebugEnabled()) {\n                        NAMING_LOGGER.debug(\"request {} failed.\", server, e);\n                    }\n                }\n                index = (index + 1) % servers.size();\n            }\n        }\n        \n        NAMING_LOGGER.error(\"request: {} failed, servers: {}, code: {}, msg: {}\", api, servers,\n            exception.getErrCode(),\n            exception.getErrMsg());\n        \n        throw new NacosException(exception.getErrCode(),\n            \"failed to req API:\" + api + \" after all servers(\" + servers + \") tried: \"\n                + exception.getMessage());\n        \n    }\n    \n    /**\n     * Call server.\n     *\n     * @param api       api\n     * @param params    parameters\n     * @param body      body\n     * @param curServer ?\n     * @param method    http method\n     * @return result\n     * @throws NacosException nacos exception\n     */\n    public String callServer(String api, Map<String, String> params, Map<String, String> body,\n        String curServer,","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java#L404-L440","documentation":"Thrown by NamingHttpClientProxy.reqApi after exhausting all servers in the list (or all maxRetry attempts in domain mode) without a successful response. The exception preserves the last server's error code and message. This is the HTTP proxy's all-servers-failed terminal error.","triggerScenarios":"Every callServer attempt in the retry loop threw a NacosException — meaning each server in the list returned an error or was unreachable. The final thrown exception carries the last server's errorCode and a descriptive message listing the API, servers, and the last error.","commonSituations":"All Nacos servers are down or unreachable; all servers return 5xx errors due to an overload or bug; authentication failures across all servers; network partition isolating the client from the cluster.","solutions":["Check the embedded cause/last error code in the exception message to determine whether it is network (connect refused, timeout) or application (403 auth, 500 server).","Verify all Nacos server nodes are healthy and reachable on the HTTP port (default 8848).","For auth errors (403), verify the username/password or access key configuration.","Increase client read/connect timeouts if the cause is timeout under load."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"int maxRetries = 3;\nfor (int attempt = 0; attempt <= maxRetries; attempt++) {\n    try {\n        namingService.registerInstance(serviceName, instance);\n        break;\n    } catch (NacosException e) {\n        if (e.getErrMsg().contains(\"failed to req API\") && attempt < maxRetries) {\n            Thread.sleep(1000L * (attempt + 1));\n            continue;\n        }\n        throw e;\n    }\n}","preventionTips":["Monitor Nacos server health and ensure at least one node is always reachable.","Parse the embedded error code in the message to distinguish auth/network/server errors.","Configure appropriate timeouts and retry budgets for the HTTP naming proxy.","Verify auth credentials if the embedded error code is 403."],"tags":["naming","http-proxy","all-servers-failed","network","retry"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}