Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Error 429: Too Many Requests #601

Closed
arslandogar opened this issue Mar 26, 2020 · 20 comments
Closed

HTTP Error 429: Too Many Requests #601

arslandogar opened this issue Mar 26, 2020 · 20 comments

Comments

@arslandogar
Copy link

This piece of code

from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=tPEE9ZwTmy0')

Throws this error:

Traceback (most recent call last):
File "test.py", line 2, in
yt = YouTube('https://www.youtube.com/watch?v=tPEE9ZwTmy0')
File "/home/user/.local/lib/python3.6/site-packages/pytube/main.py", line 91, in init
self.prefetch()
File "/home/user/.local/lib/python3.6/site-packages/pytube/main.py", line 162, in prefetch
self.watch_html = request.get(url=self.watch_url)
File "/home/user/.local/lib/python3.6/site-packages/pytube/request.py", line 36, in get
return _execute_request(url).read().decode("utf-8")
File "/home/user/.local/lib/python3.6/site-packages/pytube/request.py", line 24, in _execute_request
return urlopen(request) # nosec
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 564, in error
result = self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 429: Too Many Requests

@dada2010
Copy link

dada2010 commented Apr 3, 2020

I have the same question, did you solve it?

@AliAkhtari78
Copy link

Same Problem.

@bigsandip
Copy link

Waiting for the solution

@swiftyy-mage
Copy link
Contributor

@ZD511 @AliAkhtari78 @bigsandip

Me and @arslandogar were discussing this issue here, I was not able to replicate the behaviour on my machine, and was not able to solve it.

Just a few questions that would be helpful if you could answer:

  1. Did this ever work for you? If it did work for you previously, when did it stop working?
  2. Does this issue happen 100% of the time for you when trying to use it?
  3. Does youtube-dl work for you?
  4. Is YouTube blocked in your country?
  5. Have you tried using a VPN?
  6. What version of Python and what version of pytube are you running?
  7. What operating system are you running?

I would recommend you all uninstall pytube completely, make sure it is uninstalled, then install pytube3 and try again. It is best actually if you can create a virtual environment and run

pip install pytube3

inside that virtual environment. I hope I can get this working for all of you.

@bigsandip
Copy link

On localserver it always works but not on live website.I heard this happens because youtube blocked my ip address. Is it true?

@dada2010
Copy link

dada2010 commented Apr 9, 2020

I solved it by 'pip uninstall pytube', 'pip uninstall pytube3' and change IP, and I think the main problem is IP been banned.

@swiftyy-mage
Copy link
Contributor

@ZD511 I am glad to hear it! Did you change your IP by resetting the router? Or did you contact your ISP or use a VPN? I hope this will work for everyone else, thank you.

@alaa-aqeel
Copy link

i fixed this error with add cookies for browser ( Firefox, Chrome ) to request
by use this : browser_cookie3

pytube/request.py

@gdimitrovdev
Copy link

I have the same problem so I tried @alaaprog's solution but now I get the following error. Can someone help me?
image

@alaa-aqeel
Copy link

@G060N0FF this lib browser_cookie3 need brwoser like firefox or chrome to get cookies from it

@gdimitrovdev
Copy link

Yeah but how exactly do I get them? Sorry I am not very good with this technology.

@gdimitrovdev
Copy link

Ah nevermind, I saw that my Cookie file corrupted so I deleted it and created a new one, now everything is working fine. Thanks!

@godfrednanaowusu
Copy link

godfrednanaowusu commented Jul 9, 2020

Is there any solution for this please, the issue is still there as at 9th July 2020. since March 26, there hasnt been any clear solution. Please if you know how to prevent Youtube from Banning IP Address, kindly let us know.

@shocklet
Copy link

i fixed this error with add cookies for browser ( Firefox, Chrome ) to request
by use this : browser_cookie3

pytube/request.py

Thanks for your help, I solved the problem by doing just like you.

@shihyuuuuuuu
Copy link

I have the same problem so I tried @alaaprog's solution but now I get the following error. Can someone help me?
image

I have the same BrowserCookieError, could you please tell me how you solved this problem? Thank you.

@infinity-plus
Copy link

Ok, if the issue is fixed by setting up cookies, how can I do it in servers like heroku?
fix on repo is needed

@RONNCC
Copy link
Collaborator

RONNCC commented Oct 31, 2020

Hi @arslandogar , @infinity-plus , @shihyuuuuuuu @shocklet @godfrednanaowusu

Am closing issue as it has been quite a while -- feel free to reopen if this issue still exists 😄

Thanks

@RONNCC RONNCC closed this as completed Oct 31, 2020
@supermomie
Copy link

Your IP has been locked for 24h that's why u have http err 429

@Teemo15
Copy link

Teemo15 commented Nov 13, 2021

File "/home/youtubbb/.local/lib/python3.9/site-packages/pytube/request.py", line 55, in get
return _execute_request(url).read().decode("utf-8")
File "/home/youtubbb/.local/lib/python3.9/site-packages/pytube/request.py", line 34, in _execute_request
cookies_jar = browser_cookie3.chrome(domain_name='.youtube.com')
File "/home/youtubbb/.local/lib/python3.9/site-packages/browser_cookie3/init.py", line 662, in firefox
return Firefox(cookie_file, domain_name).load()
File "/home/youtubbb/.local/lib/python3.9/site-packages/browser_cookie3/init.py", line 496, in init
cookie_file = cookie_file or self.find_cookie_file()
File "/home/youtubbb/.local/lib/python3.9/site-packages/browser_cookie3/init.py", line 569, in find_cookie_file
raise BrowserCookieError('Failed to find Firefox cookie')
browser_cookie3.BrowserCookieError: Failed to find Firefox cookie

How can I fix this?

@RONNCC
Copy link
Collaborator

RONNCC commented Nov 14, 2021

Hey @Teemo15 -- please create a new issue in order to keep this one on topic :-)
also helps us sort + organize them for the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests