502 errors in mentions_timeline


I have a script up that is pinging statuses/mentions_timeline. About half of the time, the script works fine, but the other half I’m running into 502 errors. It’s erratic, and I’m checking my rate limits to make sure that I’m not running into rate limit errors. Here are the parameters that I have:

include_entities=True, contributor_details=True, include_rts=False, count=100

Any insight on this?


Hi @brain_deer,

502 errors typically happen when the request takes longer than expected to process. Do you ever use since_id or max_id when issuing requests to the mentions timeline or are you always just asking for count=100 without it? What’s the user account you’re requesting these on behalf of? Do you notice any difference if you use a lower count value?


@episod - thanks for your response. I switched the count to count=50 and I’m getting way better results now. There are multiple user accounts that I’m requesting on behalf of, although I’d rather not name them. Also I’m making multiple requests to the mentions_timeline. I’ll make the first request without max_id and make any subsequent tests with a max_id that I get from the previous request.

For now I’m going to keep the count at 50 and keep checking for errors. Obviously, any more recommendations would be appreciated and thanks for your help :D.


If you want to let me know the usernames privately, it would be helpful to investigate why their mentions timeline 502s so often: episod@twitter.com – otherwise, I’ll have to wait for others to report similar problems to further investigate.