All tools / Gateway
Gateway close code explainer
Look up a Discord gateway close code (4000–4014, 1000/1001) and whether your bot should reconnect.
Result
Reconnect or stop
4004, 4010, 4011, 4012, 4013, and 4014 will fail again on every retry until you change the token, shard config, version, or intents. Closing your own socket with 1000 or 1001 invalidates the session, so the bot goes offline instead of resuming.
Related: Privileged intents checklist · Gateway heartbeat interval helper