Discord · api · fg-0443

Discord bot suddenly fails to log in after its token was pushed to a public GitHub repo or gist

If you see Gateway closed with code 4004 Authentication failed, the cause and the fix for Discord are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Gateway closed with code 4004 Authentication failed401: Unauthorized on every REST callBot worked an hour earlier and nothing changed in the hosting
Cause
Discord bot tokens are a GitHub secret scanning partner pattern, so a token in a public commit, gist, issue or npm package is reported straight to Discord. The provider can revoke it, and the bot then fails with an authentication error.
Fix
Reset the token in the Developer Portal, store it as a deploy secret, and scrub it from git history. Enable push protection on the repository.
Apply
https://discord.com/developers/applications > your app > Bot > Reset Token > store the new value in the host's secret manager
Affected
Discord bot tokens found in public GitHub content, as of 2026-10
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun