Getting 401 errors from 'statuses/filter' on hosted environment, but not on dev machine


I have a very weird issue I can’t seem to pinpoint no matter what I do.
We have an application that has been working fine for the last few months, but it stopped working over the last few days.
When the application tries to open a stream from the Streaming API to the ‘statuses/filter’ end point, the response returns an error with a 401 (unauthorized) status code.
This happens on both hosted environments we’re testing on- Microsoft Azure and Nodejitsu.
One weird part is that using the exact same code on a local machine and running it through “localhost” works with no issues what-so-ever. Tweets are being streamed, and everything’s peachy.
Another weird part is that there were at least two short periods of time in which the the application running on hosted environments managed to connect successfully to the end point and stream the tweets as requested. This seems to be on and off.

I’m frustrated by this for the last three days with no clue on how to fix it.
Any ideas? anyone else experiencing the same?


What does the body of the error response tell you?

Are your IP addresses dedicated? Have you verified the server clocks on your remote servers to make sure they’re within <5 minutes of our own? (We return our system clock in the Date header of each response). Have you verified that all your API keys and tokens are correct, current, and valid? Are you keeping your connections to a single open stream?


EDIT: I think this was an issue on our end. Please don’t waste any time investigating it. Sincere apologies.

We are experiencing an issue in production which looks identical to what Naor Biton described. Our client is using API 1.1, and sends a POST to statuses/filter with the ‘track’ param, keeps the connection alive, and reads the stream of tweets. This works fine, sometimes … but sometimes it gets a 401 response, in spite of the access token being valid (I have confirmed this with a GET to the account/verify_credentials.json endpoint, from the same server, with the same token). The server has a dedicated IP. The clock is correct. The problem is intermittent, and is happening frequently … enough to cause a real problem for us. Below is the body of the 401 response from Twitter. Please, let me know if there’s anything else I can provide that might help Twitter diagnose and fix this issue. Again, this problem is intermittent … our client works fine sometimes, and then will get 401s, without any changes. I do not think it’s a problem with our client, and it certainly doesn’t appear to be a problem with authentication, as Twitter’s response indicates. The token is still valid. Please advise, is there an open issue being tracked regarding this? I’ve done some searching, and I see similar issues described in the past, but everything recent I could find seems to indicate that Twitter considers this fixed/closed.

Response body (nothing special, but for completeness):

Error 401 Unauthorized


Problem accessing '/1.1/statuses/filter.json'. Reason:



I am having the exact same problem. And it’s been like this for about a week now.


I was also facing the same issue. Works fine on local machine but doesn’t work on server. It was always a 401. Turns out the problem was system time. It was roughly about 7 minutes behind (slower) compared to my local system time (when converted to UTC). I believe the nonce and hash used in OAuth headers have a timeout and that resulted in 401.

Hope this helps someone who comes here looking for a solution to this problem.

P.S : The server is a Ubuntu 14 LTS. Network time update is/was on. Still it was slow. I have seen this on a few Ubuntu servers running on AWS. Had to update it manually.