Discord API · error code

Discord error 10004: Unknown guild

Permanent - do not retryHTTP 404Unknown resource (10xxx)

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
Unknown guild

What error 10004 means

The guild (server) ID in your request does not resolve to a guild your bot can see. Unlike channels, guild visibility is binary: the bot is either a member or it is not. So 10004 almost always means one of two things, the ID is wrong, or the bot was removed from that server.

Bots get removed more often than developers expect. A server admin kicks the bot, the server is deleted, or the bot was never actually invited and the ID was copied from a test server. Because the bot process keeps running, the first symptom is a flood of 10004 from a scheduled task that still iterates over the stale guild ID.

It is also returned on some OAuth2 and application command routes when the guild ID is valid but the application has no presence there, for example registering guild commands in a server where the bot was never added with the applications.commands scope.

What it looks like

{
  "message": "Unknown Guild",
  "code": 10004
}

Why it happens

  • Bot was kicked from the server or the server was deleted
  • Guild ID copied from the wrong server, or a channel/user ID used by mistake
  • Registering guild-scoped slash commands in a guild the application was not invited to
  • Snowflake precision loss when the ID passed through a numeric type
  • Sharded bot querying a guild that belongs to a different shard's cache (library-level, not the REST API)

How to fix Discord error 10004

  1. 1Call GET /users/@me/guilds and check whether the guild appears; if not, re-invite the bot with the correct scopes
  2. 2Verify the ID with Developer Mode > Copy Server ID and compare the string exactly
  3. 3For slash commands, confirm the invite URL included scope=bot%20applications.commands
  4. 4On GUILD_DELETE events with unavailable=false, purge the guild from your database so jobs stop targeting it
  5. 5Check the shard calculation ((guild_id >> 22) % shard_count) if the error comes from a library cache lookup rather than REST

How to stop it recurring

Drive any per-guild work from the live guild list or the GUILD_CREATE/GUILD_DELETE event stream rather than from a static table. Keep a last-seen timestamp per guild and skip rows that have not produced an event recently. This also avoids wasting requests that count toward the invalid request limit.

A guild that disappears takes its channels, roles and webhooks with it, so a burst of 10003 and 10015 alongside 10004 usually has the single root cause of a lost guild rather than three separate bugs.

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

Related codes

Error 10004 - quick answers

What does Discord error 10004 mean?

The guild (server) ID in your request does not resolve to a guild your bot can see. Unlike channels, guild visibility is binary: the bot is either a member or it is not. So 10004 almost always means one of two things, the ID is wrong, or the bot was removed from that server. Bots get removed more often than developers expect.

How do I fix Discord error 10004?

1. Call GET /users/@me/guilds and check whether the guild appears; if not, re-invite the bot with the correct scopes 2. Verify the ID with Developer Mode > Copy Server ID and compare the string exactly 3. For slash commands, confirm the invite URL included scope=bot%20applications.commands 4. On GUILD_DELETE events with unavailable=false, purge the guild from your database so jobs stop targeting it 5. Check the shard calculation ((guild_id >> 22) % shard_count) if the error…

Should I retry after error 10004?

No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.

Stop debugging Discord by hand

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