Discord API · error code

Discord error 4013: Invalid intent(s)

ConfigurationGateway close codes (4000-4014)

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value.

What error 4013 means

The intents integer in your Identify payload contains a bit that does not correspond to any gateway intent. Intents are a bitfield: each intent is 1 << n and you OR them together. If the resulting number has a bit set in a position Discord does not define, the connection is closed with 4013. It is marked not reconnectable.

This is distinct from 4014, which is about a real intent you are not allowed to use. 4013 is arithmetic: you computed the number wrong. Common ways to do that are hand-typing a decimal value from a blog post that is now stale, copying an intents calculator output that included a typo, using + on values that overlap instead of |, passing the intents as a string, or using a library's "all intents" constant from a version that predates newer intents (which is safe) versus a home-grown "all bits set" value like 0xFFFFFFFF (which is not, because it sets undefined bits).

A worked example makes the arithmetic concrete. GUILDS is 1 << 0 = 1, GUILD_MESSAGES is 1 << 9 = 512, MESSAGE_CONTENT is 1 << 15 = 32768; OR them together and you get 33281, a valid intents value. Set bit 20 by hand, or send 4294967295 to "enable everything", and the payload contains positions Discord has never defined, so the socket closes with 4013 before the session exists. Because it is marked not reconnectable, a client that retries the same Identify in a loop fails identically every time while draining the daily session_start_limit identify budget, after which even a corrected build cannot connect until the window resets. Fix the number first, then restart: intents are only read at Identify, so a running process never picks up a corrected value.

What it looks like

// WebSocket close frame
code: 4013
reason: "Invalid intent(s)"

// valid example: GUILDS (1<<0) | GUILD_MESSAGES (1<<9) | MESSAGE_CONTENT (1<<15)
{ "op": 2, "d": { "token": "...", "intents": 33281, "properties": { ... } } }

Why it happens

  • Hand-computed intents integer with an undefined bit set
  • Setting every bit (e.g. 2^32 - 1) instead of ORing defined intents
  • Passing intents as a string or float
  • Outdated or mistyped value copied from a tutorial
  • Library version mismatch where a named intent maps to an undefined bit

How to fix Discord error 4013

  1. 1Use your library's named intent constants (GatewayIntentBits.Guilds, discord.Intents.default(), etc.) and let it compute the integer
  2. 2Log the final intents integer and check it in binary against the documented intent list
  3. 3Replace any all-bits value with the library's all/ALL constant, or list exactly the intents you need
  4. 4Ensure intents is sent as a JSON integer, not a string

How to stop it recurring

Never hand-write the intents number. Declare intents by name in code so the list is readable in review, and let the library serialize it. If you maintain a custom client, keep a single enum of intent bits synced with the docs and compute from that.

The gateway table on the Discord limits page lists the identify budget this error can drain, and the 4013-versus-4014 comparison table in Discord bot not responding shows both failures side by side.

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

Related codes

Error 4013 - quick answers

What does Discord error 4013 mean?

The intents integer in your Identify payload contains a bit that does not correspond to any gateway intent. Intents are a bitfield: each intent is 1 << n and you OR them together. If the resulting number has a bit set in a position Discord does not define, the connection is closed with 4013. It is marked not reconnectable. This is distinct from 4014 , which is about a real intent you are not allowed to use.

How do I fix Discord error 4013?

1. Use your library's named intent constants (GatewayIntentBits.Guilds, discord.Intents.default(), etc.) and let it compute the integer 2. Log the final intents integer and check it in binary against the documented intent list 3. Replace any all-bits value with the library's all/ALL constant, or list exactly the intents you need 4. Ensure intents is sent as a JSON integer, not a string

Stop debugging Discord by hand

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