Discord API · error code

Discord error 40333: Cloudflare blocking request

ConfigurationTokens and OAuth2

Last verified against Discord Developer Docs - Opcodes and status codes

What Discord returns
Cloudflare is blocking your request. This can often be resolved by setting a proper User Agent

What error 40333 means

Discord's edge, which is fronted by Cloudflare, refused the request before it reached the API. The message points at the most common fix: the User-Agent header. Discord's API reference asks every client to send a User-Agent in the form DiscordBot ($url, $versionNumber). Requests with no User-Agent, or with a default one from an HTTP library or a scripting tool, are much more likely to be blocked.

The second common cause is the IP address. Discord caps invalid requests (responses with 401, 403 or 429) at 10,000 per 10 minutes per IP. A bot stuck in a loop on a bad token or a missing permission can exceed that, and the IP is then temporarily restricted. Shared hosting and free platforms where many bots share one IP are also frequently blocked because of other tenants.

Your bot code may be fine; the request is being judged by its headers and origin.

What it looks like

{
  "message": "Cloudflare is blocking your request. This can often be resolved by setting a proper User Agent",
  "code": 40333
}

Why it happens

  • Raw HTTP requests with no User-Agent or a generic library default
  • IP restricted after exceeding 10,000 invalid requests in 10 minutes
  • Shared hosting IP blocked because of other users' traffic
  • Retry loop hammering the API after 401 or 403 responses

How to fix Discord error 40333

  1. 1Set User-Agent to DiscordBot (your-url, your-version) on every request
  2. 2Search your logs for repeated 401, 403 or 429 responses and stop the loop causing them
  3. 3Wait for the restriction to clear before restarting, rather than restarting repeatedly
  4. 4If you are on shared hosting, move the bot to a host with a dedicated IP
  5. 5Use a maintained Discord library, which sets the header and handles rate limits

How to stop it recurring

Never retry on 401 or 403; fix the cause. Count invalid responses and halt the process well before the 10,000 threshold. The invalid-request limit is on the Discord limits page, and token failures that start these loops are on 40001.

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

Related codes

Error 40333 - quick answers

What does Discord error 40333 mean?

Discord's edge, which is fronted by Cloudflare, refused the request before it reached the API. The message points at the most common fix: the User-Agent header. Discord's API reference asks every client to send a User-Agent in the form DiscordBot ($url, $versionNumber) . Requests with no User-Agent, or with a default one from an HTTP library or a scripting tool, are much more likely to be blocked.

How do I fix Discord error 40333?

1. Set User-Agent to DiscordBot (your-url, your-version) on every request 2. Search your logs for repeated 401, 403 or 429 responses and stop the loop causing them 3. Wait for the restriction to clear before restarting, rather than restarting repeatedly 4. If you are on shared hosting, move the bot to a host with a dedicated IP 5. Use a maintained Discord library, which sets the header and handles rate limits

Stop debugging Discord by hand

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