502 Gateway errors when registering WebHooks



Hi, It seems I’m the only one having this problem :sweat_smile: (I hope not ).

I’m trying to register a new webhook with this URL: https://api.twitter.com/1.1/account_activity/all/:env_name/webhooks.json

I’ve made a POST to this URL and I made sure I passed the Webhook URL as an encoded parameter.

The problem is that I get a “502 Bad Gateway” Error when twitter calls the WebHook, I’m using Ngrok locally so I was able to replay the request. When I replay the request, I don’t get the error and the code works as expected.
It also works If I access it through the browser.

I thought this was a problem with Ngrok, so I decided to switch to serveo (http://serveo.net/) I got the same 502 Bad Gateway.

I decided to finally take the bull by the horn and use Nginx directly on my production server and I’m still getting “502 Bad Gateway” :frowning_face: Like I said earlier, If I access my webhook URL through the browser everything works.

I’m starting to think there’s a problem with the way twitter calls my WebHook (Because I’ve tried three options and they all behave the same way.)

I’ve inspected the Nginx log and I noticed that twitter doesn’t send a “User-Agent” header (It’s blank) - - [13/Oct/2018:11:43:37 +0000] "GET /twitter/webhooks?crc_token=xxxxxxxxxx&nonce=MTUzOTQzMTAxNzI1Ng HTTP/1.1" 502 182 "-" "-"

could that be the problem?

By the way, I’m using Go (Maybe twitter doesn’t like Go :smile: ) But I can confirm that the API call from twitter doesn’t reach the application, It’s automatically rejected by the Proxy server (Ngrok, serveo or Nginx). I don’t know why.

If anyone uses Nginx as their proxy server, Please I’d love to see your configuration


Have you tried using one of our existing libraries to access the API?

I was able to get set up with the account activity dashboard just now, so this is likely not an issue with the product.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.