Skip to content
Sign upLog in
← Back to Community

Discord Bot: How to fix 429 rate limit error?

Profile icon
JeffKamo

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 [earned 5 cycles]
View Answer
Voters
Profile icon
Xyberneverfolds
Profile icon
GrupoHackathon
Profile icon
eric70230
Profile icon
Paul-VincentVi4
Profile icon
VladJohnson
Profile icon
zekyman99
Profile icon
devplodocus
Profile icon
muffinsbio
Profile icon
ricardoTSN
Profile icon
ForsakenWorld
Comments
hotnewtop
Profile icon
JeffKamo

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.

Profile icon
itchono

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

Profile icon
scooterb852

@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?

Profile icon
JeffKamo

@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

Profile icon
scooterb852

@JeffKamo
ty!

Profile icon
ooliver

Very long time ago but why mark your own answer as correct not theirs?

@itchono

Profile icon
JeffKamo

@ooliver
that was me. I tried setting my comment to the answer, but Replit doesn't seem to let me.

Profile icon
Aardvark7447

@JeffKamo
Thank you!

Profile icon
ninjadev64

@JeffKamo
Thank you, this worked for me!

Profile icon
Victorious100

@JeffKamo
Hey i know this and i always to this, but today when i did kill 1 it was successful but when i ran the repl, the timeout is existing

Profile icon
JC51

@JeffKamo
Jesus Christ THIS WORKS PERFECTLY!

Profile icon
ColossalTitan

You can add a line as such:

import os try: bot.start(token) except: os.system("kill 1")
Profile icon
ClementLSW

@ColossalTitan
somehow manually using the shell to run 'kill 1' didn't work but this did. Thanks a bunch!

Profile icon
Celesu

@ColossalTitan
tyvm for saving me :')

Profile icon
rcbielak

@ColossalTitan
how would I accomplish the same thing using node js? sorry for the probably newbie-level question, I only know enough about coding to be dangerous... this is what the (I think) relevant section of code currently looks like:

client.on('ready', () => { console.log("I'm in"); console.log(client.user.username); }); client.login(process.env.TOKEN)
Profile icon
EnderMarkoth

omg...u have discord!! SAMEEEEE

Profile icon
ooliver

Wow a social media? Nobody’s got that

@EnderMarkoth

Profile icon
PikachuB2005

@ooliver
lol

Profile icon
Coder100

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:

image

on the bot end, you see the error.

Solution

have it not spam smh

Profile icon
JeffKamo

@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.

Profile icon
ninjadev64

@Coder100

  1. it's limiting the host container not the bot

  2. light mode

Profile icon
Danspotnytool

@ninjadev64
lmao that's a good point