Error: Bad Twitter streaming request: 401


I am using npm twit package with node.js.
The code is

var chennai=['79.86','12.62','80.28','13.21']
var stream ='statuses/filter', { locations:chennai})
stream.on('tweet', function(tweet) {

It is working fine wtih windows7 but it is not working with ubuntu 12. it gives me an error

Error: Bad Twitter streaming request: 401
    at ClientRequest.<anonymous> (/node/node_twitter/node_modules/twit/lib/oarequest.js:202:19)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1692:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1587:20)
    at [as _read] (tls.js:513:12)
    at (_stream_readable.js:340:10)
    at EncryptedStream.write [as _write] (tls.js:368:25)
    at doWrite (_stream_writable.js:225:10)

could any one help me to solve this please


Error 401 means unauthorized. If you are using the exact same code on both platforms, with the same node version etc, then I’m a little puzzled. Are you trying to run these simultaneously?

I wonder if there is an issue with TLS or certs etc between the two platforms - that would point to a security error like this too.


Hello andypiper,
Thanks for your reply… Actually api request check for time in my computer. I changed my system time and data to correct time then its working fine. Even 5 minits delay througs error as “bad twitter streaming request :401” For simple thing I wasted lot of time HUhhh… Thanks a lot for your reply Mr. andypiper.


Glad to hear you’re all set!