pytrends 429 TooManyRequestsError: why it happens and 3 ways to fix it (2026)
Disclosure: I built the Apify Actor mentioned in fix 3, so I'm biased. Apify links here are referral links. Fixes 1 and 2 don't need it at all. Your Google Trends script worked yesterday. Today it stops with: pytrends.exceptions.TooManyRequestsError: The request failed: Google returned a response with code 429 Here is what that error means, what state pytrends is in today, and three ways to get…
Pytrends 429 TooManyRequestsError occurs when Google returns a response with code 429, indicating too many requests. This happens because pytrends doesn't use an official API and sends the same requests as trends.google.com. Google rate-limits these requests, so when Google answers with HTTP status 429, pytrends raises TooManyRequestsError. This error can happen regardless of the device used (laptop, cloud server, or shared IP).
To fix the 429 error, three methods are presented: sending fewer requests, backoff on 429, and caching everything for free. The first method involves reusing one TrendReq object instead of creating one per keyword and batching up to five keywords per payload. The second method suggests backoff exponentially on TooManyRequestsError, with some random jitter, instead of retrying immediately. The third method recommends caching results on disk, as last year's weekly interest doesn't change.
The code provided implements these fixes, creating a TrendReq() once, building payload, fetching interest over time, and caching results on disk. The code also includes a function to handle requests with backoff on 429 errors and cache the results. The script ran successfully on November 18, 2026, fetching both batches and reading results from trends_cache/ without contacting Google the second time.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.