{"record":{"id":"b327953130c2e189","repo":"RocketChat/Rocket.Chat","slug":"authorization-failed-when-sending-push-to-gateway","errorCode":null,"errorMessage":"authorization failed when sending push to gateway. not retrying.","messagePattern":"authorization failed when sending push to gateway\\. not retrying\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/meteor/server/lib/notifications/push/push.ts","lineNumber":300,"sourceCode":"\t\t\t...(token && this.options.getAuthorization && { headers: { Authorization: await this.options.getAuthorization() } }),\n\t\t} as ExtendedFetchOptions;\n\n\t\tconst result = await fetch(`${gateway}/push/${service}/send`, options);\n\t\tconst response = await result.text();\n\n\t\tif (result.status === 406) {\n\t\t\tlogger.info({ msg: 'removing push token', token });\n\t\t\tthis.removeToken(token);\n\t\t\treturn;\n\t\t}\n\n\t\tif (result.status === 422) {\n\t\t\tlogger.info({ msg: 'gateway rejected push notification. not retrying.', response });\n\t\t\treturn;\n\t\t}\n\n\t\tif (result.status === 401) {\n\t\t\tlogger.warn({ msg: 'authorization failed when sending push to gateway. not retrying.', response });\n\t\t\treturn;\n\t\t}\n\n\t\tif (result.ok) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { tries, maxRetries } = retryOptions;\n\n\t\tlogger.error({ msg: 'Error sending push to gateway', tries, err: response });\n\n\t\tif (tries < maxRetries) {\n\t\t\t// [1, 2, 4, 8, 16] minutes (total 31)\n\t\t\tconst ms = 60000 * Math.pow(2, tries);\n\n\t\t\tlogger.log({ msg: 'Retrying push to gateway', tries: tries + 1, in: ms });\n\n\t\t\tsetTimeout(() => this.sendGatewayPush(gateway, service, token, notification, { tries: tries + 1, maxRetries }), ms);","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/notifications/push/push.ts#L282-L318","documentation":"While relaying a mobile push through the Rocket.Chat Push Gateway (the cloud service that forwards to APN/FCM), the gateway answered HTTP 401. The client logs this warning and gives up on that push — 401 means the workspace's gateway credentials are invalid or revoked, so retrying the same request cannot succeed.","triggerScenarios":"POSTing a push to the gateway returns status 401: the gateway token/registration no longer valid — workspace unregistered from cloud, credentials rotated, or the Gateway URL points at a gateway instance that does not know this workspace.","commonSituations":"Workspace cloud registration expired or was removed; self-hosted gateway with stale/incorrect tokens; mixed environments (server registered against one cloud, pointed at another gateway).","solutions":["Re-register the workspace with the cloud / connectivity services (Administration > Connectivity) to refresh gateway credentials","Check the push Gateway URL setting for typos or a stale self-hosted address","Verify server clock sync (NTP) — large drift can break signed authentication to the gateway","If self-hosting the gateway, confirm the gateway recognizes this server's token before blaming APN/FCM — the 401 comes from the gateway itself"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before relying on gateway push, confirm cloud/gateway registration\nconst registered = await checkConnectivityServiceRegistration();\nif (!registered) {\n  // re-register workspace or disable gateway push instead of sending doomed requests\n  throw new Error('Push gateway credentials invalid/missing — re-register the workspace before enabling push');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep cloud/gateway registration healthy; re-register after credential rotations","Monitor push logs for 401/406/422 — the client does not retry 401, so failures are silent to users","Verify Gateway URL and server clock (NTP) as part of push configuration checks"],"tags":["push","gateway","http-401","authentication","mobile"],"backgroundTag":"http-401-unauthorized","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}