{"record":{"id":"4c22761baac284e5","repo":"RocketChat/Rocket.Chat","slug":"failed-to-connect-to-rocket-chat-cloud-error-4c2276","errorCode":null,"errorMessage":"Failed to connect to Rocket.Chat Cloud: ${error}","messagePattern":"Failed to connect to Rocket\\.Chat Cloud: (.+?)","errorType":"exception","errorClass":"CloudWorkspaceConnectionError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/cloud/syncWorkspace/legacySyncWorkspace.ts","lineNumber":40,"sourceCode":"\ttoken: string;\n\tworkspaceRegistrationData: WorkspaceRegistrationData<undefined>;\n}): Promise<Cloud.WorkspaceSyncPayload | undefined> => {\n\tconst workspaceRegistrationClientUri = settings.get<string>('Cloud_Workspace_Registration_Client_Uri');\n\tconst response = await fetch(`${workspaceRegistrationClientUri}/client`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${token}`,\n\t\t},\n\t\tbody: workspaceRegistrationData,\n\t\ttimeout: 5000,\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\tconst result = Cloud.WorkspaceSyncPayloadSchema.safeParse(payload);\n\n\tif (!result.success) {\n\t\tthrow new CloudWorkspaceConnectionError('Invalid response from Rocket.Chat Cloud', {\n\t\t\tcause: z.prettifyError(result.error),\n\t\t});\n\t}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/syncWorkspace/legacySyncWorkspace.ts#L22-L58","documentation":"The deprecated legacy cloud sync (fetchWorkspaceClientPayload) POSTs workspace registration data with the workspace access token as Bearer; a non-ok response with a JSON body becomes CloudWorkspaceConnectionError('Failed to connect to Rocket.Chat Cloud: <cloud error>'). The text after the colon is the cloud's rejection reason — most often an expired or revoked token, or a workspace the cloud no longer recognizes.","triggerScenarios":"legacySyncWorkspace runs (the legacy cloud sync path) while the cloud rejects the sync request: token expired or revoked, workspace deleted on the cloud side, or cloud-side processing errors.","commonSituations":"Older Rocket.Chat versions still using the legacy sync; the workspace was removed in the cloud portal; access token refresh failing for extended periods leaving a stale token.","solutions":["Read the wrapped cloud error message for the concrete rejection reason.","Re-register the workspace with the cloud using a fresh registration token (cloud:connectWorkspace).","Verify the workspace still exists in the Rocket.Chat Cloud console.","Upgrade to a current release that uses the non-legacy sync path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import { CloudWorkspaceConnectionError } from '<cloud errors module>';\n\ntry {\n  await legacySyncWorkspace();\n} catch (e) {\n  if (e instanceof CloudWorkspaceConnectionError && e.message.startsWith('Failed to connect to Rocket.Chat Cloud:')) {\n    // read the cloud's reason after the colon; expired/revoked tokens require re-registration\n  }\n  throw e;\n}","preventionTips":["Keep cloud credentials fresh — re-register promptly when tokens are revoked or workspaces removed cloud-side.","Monitor legacy sync runs; repeated connection errors mean credentials, not transient faults.","Plan migration off the deprecated legacySyncWorkspace path to the current sync implementation."],"tags":["rocket-chat","cloud","sync","deprecated"],"backgroundTag":"cloud-sync-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}