{"record":{"id":"dddc6d3e24bd7327","repo":"RocketChat/Rocket.Chat","slug":"failed-to-connect-to-rocket-chat-cloud-error","errorCode":null,"errorMessage":"Failed to connect to Rocket.Chat Cloud: ${error}","messagePattern":"Failed to connect to Rocket\\.Chat Cloud: (.+?)","errorType":"exception","errorClass":"CloudWorkspaceConnectionError","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/lib/cloud/connectWorkspace.ts","lineNumber":35,"sourceCode":"\t\tclient_name: string;\n\t\tredirect_uris: string[];\n\t};\n}) => {\n\tconst cloudUrl = settings.get<string>('Cloud_Url');\n\tconst response = await fetch(`${cloudUrl}/api/oauth/clients`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${token}`,\n\t\t},\n\t\tbody,\n\t\t// SECURITY: the URL is a default hardcoded value or an envvar/setting set by an admin. It's safe to disable this check.\n\t\tignoreSsrfValidation: true,\n\t});\n\n\tif (!response.ok) {\n\t\ttry {\n\t\t\tconst { error } = await response.json();\n\t\t\tthrow new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${error}`);\n\t\t} catch (error) {\n\t\t\tthrow new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${response.statusText}`);\n\t\t}\n\t}\n\n\tconst payload = await response.json();\n\n\tif (!payload) {\n\t\treturn undefined;\n\t}\n\n\treturn payload;\n};\n\nexport async function connectWorkspace(token: string) {\n\tassertNotOfflineLicense();\n\n\tif (!token) {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/connectWorkspace.ts#L17-L53","documentation":"fetchRegistrationDataPayload POSTs the workspace registration request to the Rocket.Chat Cloud register endpoint with the registration token as Bearer. When the cloud answers non-ok with a JSON body, this CloudWorkspaceConnectionError wraps the cloud's own error string — the text after the colon is the cloud's rejection reason, not a local one.","triggerScenarios":"connectWorkspace(token) — the cloud registration flow ('cloud:connectWorkspace' method, Setup Wizard or Admin > Cloud) — where the cloud rejects the request: expired or already-consumed registration token, invalid Organization_Email, or the workspace is already registered.","commonSituations":"Reusing a registration token after a previous attempt consumed it; a token pasted with whitespace or truncated; Organization_Email empty or malformed; cloud portal state out of sync with the workspace.","solutions":["Read the error text after the colon — it states the cloud's exact rejection reason and usually names the field at fault.","Generate a fresh registration token in the Rocket.Chat Cloud console and retry with it.","Verify Organization_Email and Site_Name settings contain valid values.","Confirm Cloud_Url points to the right cloud environment (default https://cloud.rocket.chat)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const token = tokenInput.trim();\nif (!token) throw new Error('registration token is required');","typeGuard":null,"tryCatchPattern":"import { CloudWorkspaceConnectionError } from '<cloud errors module>';\n\ntry {\n  await Meteor.callAsync('cloud:connectWorkspace', token);\n} catch (e) {\n  if (e instanceof CloudWorkspaceConnectionError) {\n    // the message after the colon is the cloud's own reason — surface it to the admin\n  }\n  throw e;\n}","preventionTips":["Generate a fresh registration token per attempt; treat tokens as single-use.","Validate Organization_Email / Site_Name before starting cloud registration.","Keep Cloud_Url on the default unless you deliberately target another cloud environment."],"tags":["rocket-chat","cloud","registration","http"],"backgroundTag":"cloud-registration-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}