{"record":{"id":"1c9c64a6fab2898b","repo":"abpframework/abp","slug":"error-remote-server-returns-response-statuscode","errorCode":null,"errorMessage":"ERROR: Remote server returns '{response.StatusCode}'","messagePattern":"ERROR: Remote server returns '(.+?)'","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs","lineNumber":141,"sourceCode":"            {\n                await LogoutAsync(accessToken);\n            }\n\n            File.Delete(CliPaths.Lic);\n        }\n    }\n\n    public async Task<bool> CheckMultipleOrganizationsAsync(string username)\n    {\n        var url = $\"{CliUrls.AccountAbpIo}api/license/check-multiple-organizations?username={username}\";\n\n        var client = CliHttpClientFactory.CreateClient();\n\n        using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger))\n        {\n            if (!response.IsSuccessStatusCode)\n            {\n                throw new Exception($\"ERROR: Remote server returns '{response.StatusCode}'\");\n            }\n\n            await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);\n\n            var responseContent = await response.Content.ReadAsStringAsync();\n            return JsonSerializer.Deserialize<bool>(responseContent);\n        }\n    }\n\n    private async Task LogoutAsync(string accessToken)\n    {\n        try\n        {\n            var client = CliHttpClientFactory.CreateClient();\n            var content = new StringContent(\n                JsonSerializer.Serialize(new { token = accessToken }),\n                Encoding.UTF8, \"application/json\"\n            );","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs#L123-L159","documentation":"Thrown by AuthService.CheckMultipleOrganizationsAsync when the HTTP GET to the abp.io license endpoint returns a non-success status code. The CLI contacts account.abp.io to determine whether a username belongs to more than one organization; any 4xx/5xx is surfaced as a generic remote error wrapping the status code.","triggerScenarios":"client.GetHttpResponseMessageWithRetryAsync(url) returns a response where IsSuccessStatusCode is false. Causes include 401/403 (auth/expired token), 404 (unknown user), 5xx (server outage), or network-level failures that still produce a status code after retries.","commonSituations":"Expired or missing ABP CLI login token; the account.abp.io service is temporarily down; rate limiting (429); corporate proxy returning an error page/status; the username does not map to a licensed account; offline/network-restricted CI environment.","solutions":["Re-authenticate with 'abp login <username>' to refresh the access token, then retry.","Check network connectivity and proxy settings; ensure account.abp.io is reachable (the CLI uses a retry policy, so transient failures are already retried).","If the server is down (5xx/429), wait and retry later.","For CI environments, run login in a prior step and persist the token, or skip license-dependent commands."],"exampleFix":"# before: token expired, command fails\nabp suite install\n# after: re-login then retry\nabp login your@username.com\nabp suite install","handlingStrategy":"retry","validationCode":"// Pre-check connectivity and a valid token before calling the license endpoint.\nif (string.IsNullOrWhiteSpace(await authService.GetAccessTokenAsync()))\n{\n    throw new InvalidOperationException(\"Not logged in. Run 'abp login' first.\");\n}\nif (!await networkProbe.CanReachAsync(new Uri(CliUrls.AccountAbpIo)))\n{\n    throw new InvalidOperationException(\"account.abp.io is not reachable; check network/proxy.\");\n}","typeGuard":"public static bool IsTransientFailure(HttpStatusCode code) =>\n    (int)code is >= 500 and (int)HttpStatusCode.ServiceUnavailable or 429;","tryCatchPattern":"try\n{\n    var multiple = await authService.CheckMultipleOrganizationsAsync(username);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Remote server returns\", StringComparison.Ordinal))\n{\n    logger.LogError(ex, \"License check failed; re-login or retry later.\");\n    // Re-authenticate or surface to the user; do not silently swallow.\n    throw;\n}","preventionTips":["Run 'abp login' before license-dependent commands and keep the token current.","Ensure network/proxy allows account.abp.io in CI.","Surface status codes clearly to users instead of hiding the generic exception.","Cache license-check results to reduce calls to the remote endpoint."],"tags":["cli","network","auth","license","http"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}