Troubleshooting

429 - Too Many Requests

Instaloader has a logic to keep track of its requests to Instagram and to obey their rate limits. Since they are nowhere documented, we try them out experimentally. We have a daily cron job running to confirm that Instaloader still stays within the rate limits. Nevertheless, the rate control logic assumes that

  • at one time, Instaloader is the only application that consumes requests. I.e. neither the Instagram browser interface, nor a mobile app, nor another Instaloader instance is running in parallel,

  • no requests had been consumed when Instaloader starts.

The latter one implies that restarting or reinstantiating Instaloader often within short time is prone to cause a 429. When a request is denied with a 429, Instaloader retries the request as soon as the temporary ban is assumed to be expired. In case the retry continuously fails for some reason, which should not happen in normal conditions, consider adjusting the --max-connection-attempts option.

“Too many queries in the last time” is not an error. It is a notice that the rate limit has almost been reached, according to Instaloader’s own rate accounting mechanism. We regularly adjust this mechanism to match Instagram’s current rate limiting.

Login error

Instaloader’s login should work fine, both with and without Two-Factor-Authentication. It also supports handling the checkpoint challenge, issued when Instagram suspects authentication activity on your account, by pointing the user to an URL to be opened in a browser.

Nevertheless, in issue #92 users report problems with logging in. To still use Instaloader’s logged-in functionality, you may use the following script to workaround login problems by importing the session cookies from Firefox and bypassing Instaloader’s login.

from glob import glob
from os.path import expanduser
from sqlite3 import connect

from instaloader import ConnectionException, Instaloader

# FIREFOXCOOKIEFILE = "/home/alex/.mozilla/firefox/l96w6b90.default/cookies.sqlite"
FIREFOXCOOKIEFILE = glob(expanduser("~/.mozilla/firefox/*.default/cookies.sqlite"))[0]

instaloader = Instaloader(max_connection_attempts=1)
instaloader.context._session.cookies.update(connect(FIREFOXCOOKIEFILE)
                                            .execute("SELECT name, value FROM moz_cookies "
                                                     "WHERE baseDomain='instagram.com'"))

try:
    username = instaloader.test_login()
    if not username:
        raise ConnectionException()
except ConnectionException:
    raise SystemExit("Cookie import failed. Are you logged in successfully in Firefox?")

instaloader.context.username = username
instaloader.save_session_to_file()

To use this,

  1. login to Instagram in Firefox,

  2. execute the snippet,

  3. then, instaloader -l USERNAME should work fine.

If you do not use your default firefox profile, or your operating system has the paths differently set up, you may have to alter the FIREFOXCOOKIEFILE variable first.

Next Section

Contributing to Instaloader

Table of Contents