Ask coding questions

← Back to all posts
Discord Bot: How to fix 429 rate limit error?
JeffKamo (5)

I am following a guide I found for creating a Discord Bot, but when I run their example code I hit a 429 error "You are being rate limited" error.

I only ran my bot once and got this error. Why am I being rate limited?

Is this similar to a similar sounding issue I discovered on Glitch's forums where their host server is getting rate limited rather than my specific bot?

Example of the error:

Traceback (most recent call last):
  File "main.py", line 18, in <module>
    client.run(os.getenv('TOKEN'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 718, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 697, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 660, in start
    await self.login(*args, bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 509, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 293, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 209, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0)
Answered by itchono (7) [earned 5 cycles]
View Answer
Comments
hotnewtop
JeffKamo (5)

I found a fix!

It turns out that you can run kill 1 in the shell tab to destroy the current container and switch to a new one. This fixed it for me.

Props to this thread (in Replit's Discord server) where I found the answer.

itchono (7)

@JeffKamo Thank you! I was having the same problem, and killing the container worked.

scottburba (0)

@JeffKamo this was a great help for me as well - thank you - the discord thread link is on a server i'm not on so didn't work. could u pls share the server in the post if public so i could join to see the thread?

JeffKamo (5)

@scottburba sorry about that! The link is to Replit's discord. The link to their discord should be in the footer of this site, but just in case:

https://replit.com/discord

Coder100 (18200)

Comes from

When your bot sends toom any messages in a period of time, that's called spamming
on the user end, you see this:

on the bot end, you see the error.

Solution

have it not spam smh

JeffKamo (5)

@Coder100 The rate limiting error prevented the bot from ever going live. It is impossible for a bot to spam if it never worked in the first place.

EnderMarkoth (8)

omg...u have discord!! SAMEEEEE