Twitter's & Amazon EC2


I amtry oauth_token from Amazon ec2, is not return anything fail.

If I send from godaddy twitter working find return the token abb7MdEEQ6Se3T4e7dGmfE5xoKRuhHjgOOSujLgPhQ


Amazon ban IP address for twitters or what?


is url


no oauth_token, i host my code on


Hi @peermeup,

I’m trying to understand your issue but am at a loss as to what you’re experiencing.

Can you tell me the specific API end points you are hitting? What specific error responses are you getting? In response to which methods? Are you able to make basic curl requests to the Twitter API from the same machine? Have you verified that the server’s clock is in sync with Twitter’s?


hi @episod same code working here.

but when i move the code to Amazon EC2 this not get the token from twitter.


hi @episod same code working here.

but when i move the code to Amazon EC2 this not get the token from twitter.


Hi there… I’m facing the same problem… on dev enviroment the authentication works fine, but when I put my web-app on amazon ec2 servers, twitter api just does not work for me…
an user recommends to setting up my server’s user-agent to my domain. Is this correct, and if it is, where can I change that…

Thanks in advance for your comments.


What’s the exact error you receive when executing the code on EC2 – the status code, message, and body of the response should tell you why the call could not be authorized. This is often due to clock mismatches on EC2.

The oauth/request_token and oauth/access_token end points aren’t “rate limited” in the way the proper API is. User agent has little meaning here – though it doesn’t hurt to use a unique one for proper identification.


Hi Taylor… thanks for your help…
I’m using symfony and a plugin that allows me to get connected to twitter api (sfMelody) in my localhost, the log for the request looks like this:

Oct 18 14:32:29 symfony [info] {OAuth} call with params oauth_callback=https%3A%2F%2Flocalhost%2Findex.php%2Faccess%2Ftwitter&oauth_consumer_key=fYUddJniczrFF3nXeLj4Ig&oauth_nonce=7dbf0ca059d64b9ed1278244554b6cf6&oauth_signature=bwOAka9KA%2FbOeuslCg0qd%2B2ZZIQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1318966349&oauth_version=1.0 |
Oct 18 14:32:30 symfony [info] {OAuth} twitter return Array
[oauth_token] => RBmkDhTNSnb4rceKnIYdZvOBH3zy5KmccJvmTRQRKA
[oauth_token_secret] => xxxxx
[oauth_callback_confirmed] => true

Oct 18 14:32:30 symfony [info] {Doctrine_Connection_Statement} execute : DELETE FROM token WHERE (status = ? AND name = ? AND user_id = ?) - (request, twitter, 1)
Oct 18 14:32:30 symfony [info] {OAuth} “twitter” call url “” with params "array (
‘oauth_token’ => ‘xxxx’,
Oct 18 14:32:30 symfony [info] {sfFrontWebController} Redirect to “

The same code and the same application running in ec2 server give me a log like this:

Oct 18 14:26:30 symfony [info] {OAuth} call with params oauth_callback=http%3A%2F%2Fec2-174-129-169-151.compute-1.amazonaws .com%2Findex.php%2Faccess%2Ftwitter&oauth_consumer_key=fYUddJniczrFF3nXeLj4Ig&oauth_nonce=f1997fa8383d1ec4e0691c68d52e1250&oauth_signature=HeU3PXPo4rozpgXhJDvFqLueLsk% 3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1318947990&oauth_version=1.0 | Oct 18 14:26:30 symfony [err] {OAuth} access token failed - twitter returns Array ( [Failed to validate oauth signature and token] => )

Oct 18 14:26:30 symfony [info] {Doctrine_Connection_Statement} execute : DELETE FROM token WHERE (status = ? AND name = ? AND user_id = ?) - (request, twitter, 1)
Oct 18 14:26:30 symfony [info] {OAuth} “twitter” call url “” with params "array (
‘oauth_token’ => NULL,
Oct 18 14:26:30 symfony [info] {sfFrontWebController} Redirect to ""

It looks like the api twitter doesn’t give me a response because I’m using an ec2 server or something like that…

Again: Thanks in advance for your help…


Thanks!!! in your response was the answer I had the same time but a diferent timezone…!!!

Again Thanks!


glad you’ve figured it out. I noticed that you posted your consumer secret in the previous post – you should probably regenerate your API key and secret and access token and access token secret to prevent your keys from getting compromised.


Hi Team,

I am getting the beloe exception when I tried to access Twitter Trends when the application is deployed in Amazon EC2. Could you please guide me what is the issue? When accessed in local machine with Tomcat server it is working fine. But when the same WAR is deployed in Amazon EC2, it is giving the below error. Any settings to be done? Please guide me. I am using twitter4j API.

Caused by:
at twitter4j.internal.http.HttpResponseImpl.(
at twitter4j.internal.http.HttpClientImpl.request(
… 32 more
Relevant discussions can be found on the Internet at: or
TwitterException{exceptionCode=[53498236-62f56a1e c0ecfc1f-fbb7d568], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.5}
at twitter4j.internal.http.HttpClientImpl.request(
at twitter4j.internal.http.HttpClientWrapper.request(
at twitter4j.internal.http.HttpClientWrapper.get(
at twitter4j.TwitterImpl.get(
at twitter4j.TwitterImpl.getAvailableTrends(
at com.twitter.tag.TwitterLocationTagHandler.doStartTag(
at org.apache.jsp.twitter_005flocations_005finclude_jsp._jspx_meth_twitter_005flocations_005f0(
at org.apache.jsp.twitter_005flocations_005finclude_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(