Discord API · error code

Discord error 4008: Rate limited

RetryableGateway close codes (4000-4014)

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this.

What error 4008 means

You exceeded the gateway send limit: 120 events per connection per 60 seconds (roughly 2 per second), across all opcodes including heartbeats. Unlike REST rate limits, the gateway does not return a 429 and wait; it closes the socket with 4008 and you must reconnect. Discord marks it reconnectable, and a Resume usually succeeds, but the events you were sending in the burst are gone.

The usual offenders are presence updates and Request Guild Members. A bot that changes its status on every message, or that requests members for many guilds in a loop at startup (for example to build a cache without the Server Members intent), will hit 120 quickly. Voice State Updates in a music bot that joins and leaves rapidly can also contribute. Heartbeats are sent by the library at the interval Discord specifies and count toward the total, but on their own they are nowhere near the limit.

The budget is small and shared by everything the connection sends: Identify, Resume, heartbeats (one every ~41 seconds, so a negligible slice), presence updates, voice state updates and member requests all draw from the same 120. Unlike a REST 429, there is no retry_after and no chance to slow down mid-window; the first payload over the line closes the socket and any sends you had queued are simply lost. The resume that follows replays missed inbound events, but your outbound burst is gone. The compounding failure is the reconnect itself: each fresh Identify consumes one of the ~1,000 daily session starts, so a bot that hits 4008 in a tight loop eventually cannot connect at all until the daily window resets, which looks like a completely unrelated outage.

What it looks like

// WebSocket close frame
code: 4008
reason: "Rate limited."

Why it happens

  • Presence update sent on every event or on a tight timer
  • Request Guild Members issued for many guilds at startup without pacing
  • Rapid voice channel join/leave cycles
  • Custom client with a bug sending duplicate heartbeats
  • Multiple shards' traffic funneled through one connection

How to fix Discord error 4008

  1. 1Reconnect and resume (libraries do this automatically)
  2. 2Rate limit your own outbound gateway payloads: a token bucket of ~110 per 60 seconds leaves headroom for heartbeats
  3. 3Set presence once on READY and only change it on meaningful state changes, at most every few minutes
  4. 4Pace Request Guild Members and prefer the Server Members intent plus GUILD_CREATE member lists where possible
  5. 5For large bots, add shards so per-connection traffic drops

How to stop it recurring

Put every outbound gateway send behind a single queue with a 120-per-60s budget and a small reserve for heartbeats. Audit presence-update call sites; they are almost always the culprit when 4008 appears.

The 120-per-60s figure and the session start budget it interacts with are on the Discord limits page; for pacing strategy that applies across platforms, see chatbot API rate limiting.

Official reference: Discord Developer Docs - Opcodes and status codes. See all Discord error codes or the Discord limits and quotas.

Related codes

Error 4008 - quick answers

What does Discord error 4008 mean?

You exceeded the gateway send limit: 120 events per connection per 60 seconds (roughly 2 per second), across all opcodes including heartbeats. Unlike REST rate limits, the gateway does not return a 429 and wait; it closes the socket with 4008 and you must reconnect. Discord marks it reconnectable, and a Resume usually succeeds, but the events you were sending in the burst are gone.

How do I fix Discord error 4008?

1. Reconnect and resume (libraries do this automatically) 2. Rate limit your own outbound gateway payloads: a token bucket of ~110 per 60 seconds leaves headroom for heartbeats 3. Set presence once on READY and only change it on meaningful state changes, at most every few minutes 4. Pace Request Guild Members and prefer the Server Members intent plus GUILD_CREATE member lists where possible 5. For large bots, add shards so per-connection traffic drops

Can I retry after error 4008?

Yes - this is a retryable condition. Back off (start around one second and double on each attempt, with jitter) and watch for a retry-after hint from the platform before resending.

Stop debugging Discord by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.