instagrapi icon indicating copy to clipboard operation
instagrapi copied to clipboard

" too many 429 error responses " in login request

Open farhadyazdani401 opened this issue 2 years ago • 12 comments

i have error " too many 429 error responses " when i request to login. it was workin fine before upgrading instagrapi. what's the problem?

farhadyazdani401 avatar Apr 21 '23 16:04 farhadyazdani401

I have a similar problem, don't think it depends on the library, most likely the problem is in the Instagram API

100rmk avatar Apr 21 '23 18:04 100rmk

I have a similar problem, don't think it depends on the library, most likely the problem is in the Instagram API

before i upgrade lib, the lib was automatically ignoring 429 error but now doesn't do it

farhadyazdani401 avatar Apr 21 '23 19:04 farhadyazdani401

@farhadyazdani401 please help me fix this if you can reproduce the problem

adw0rd avatar Apr 21 '23 19:04 adw0rd

@farhadyazdani401 please help me fix this if you can reproduce the problem

i simply use code below to login:

cl = Client() time.sleep(random.randint(1,5)) cl.login(username, password)

and then i get this error:

Traceback (most recent call last): File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 878, in urlopen return self.urlopen( ^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 868, in urlopen retries = retries.increment(method, url, response=response, _pool=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/accounts/contact_point_prefill/ (Caused by ResponseError('too many 429 error responses'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:\py\insta\Bot\ex.py", line 57, in cl.login(usernam, password) File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 383, in login self.pre_login_flow() File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 47, in pre_login_flow self.set_contact_point_prefill("prefill") File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\auth.py", line 150, in set_contact_point_prefill
return self.private_request("accounts/contact_point_prefill/", data, login=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 480, in private_request raise e File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 465, in private_request self._send_private_request(endpoint, **kwargs) File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\instagrapi\mixins\private.py", line 313, in _send_private_request
response = self.private.post( ^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 635, in post return self.request("POST", url, data=data, json=json, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\FARHAD\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 556, in send raise RetryError(e, request=request) requests.exceptions.RetryError: HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/accounts/contact_point_prefill/ (Caused by ResponseError('too many 429 error responses'))

farhadyazdani401 avatar Apr 21 '23 19:04 farhadyazdani401

Custom waits between requests?

2023-04-21 12:31:21,366 [INFO ] xxxxxxxxx [401] POST https://i.instagram.com/api/v1/feed/timeline/ (269.0.0.18.75, OnePlus 6T Dev) 2023-04-21 12:31:21,373 [INFO ] Couldn't login user using session information: Please wait a few minutes before you try again. 2023-04-21 12:31:21,373 [INFO ] Attempting to login via username and password. username: xxxxxxxxx 2023-04-21 12:31:22,737 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:25,963 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:29,168 [INFO ] [None] [401] GET https://www.instagram.com/xxxxxxxxx/?__a=1&__d=dis 2023-04-21 12:31:34,684 [ERROR] HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/users/xxxxxxxxx/usernameinfo/ (Caused by ResponseError('too many 429 error responses'))

zhito avatar Apr 22 '23 11:04 zhito

@zhito

cl = Client(request_timeout=7)

adw0rd avatar Apr 23 '23 22:04 adw0rd

still getting similar problem. I just reverted to 1.17.3 and am able to login and post successfully

ctrlvee avatar Apr 24 '23 04:04 ctrlvee

1.17.3 (below) is letting me login and post while 1.17.4 does not

(.venv) v@v instagram_post % /Users/v/Python/instagram_post/.venv/bin/python /Users/v/P ython/instagram_post/post.py Status 429: Too many requests Ignore 429: Continue login (.venv) v@v instagram_post %

ctrlvee avatar Apr 24 '23 04:04 ctrlvee

got the same issue too

mces89 avatar Apr 24 '23 06:04 mces89

still getting similar problem. I just reverted to 1.17.3 and am able to login and post successfully

The next version should be correct, the current bug edits were not uploaded to pypi

100rmk avatar Apr 25 '23 22:04 100rmk

The next version should be correct, the current bug edits were not uploaded to pypi

still getting same error version: 2.0.3 os: windows 10 python; 3.11.4

yo-aiv1 avatar Mar 06 '24 14:03 yo-aiv1

UPDATE: you can just add delay and it'll work fine, worked with 10s delay

yo-aiv1 avatar Mar 07 '24 16:03 yo-aiv1