Getting 403 error while trying to run twilio script

Whenever I try to send a SMS using the twilio library, I get the following error:

Traceback (most recent call last):
File "/home/rodrigoaraujo/", line 9, in <module>g
File "/usr/local/lib/python2.7/site-packages/twilio/rest/resources/", line 95, in createg
return self.create_instance(kwargs)g
File "/usr/local/lib/python2.7/site-packages/twilio/rest/resources/", line 225, in create_instanceg
File "/usr/local/lib/python2.7/site-packages/twilio/rest/resources/", line 121, in requestg
resp = make_twilio_request(method, uri, auth=self.auth, **kwargs)g
File "/usr/local/lib/python2.7/site-packages/twilio/rest/resources/", line 80, in make_twilio_requestg
resp = make_request(method, uri, **kwargs)g
File "/usr/local/lib/python2.7/site-packages/twilio/rest/resources/", line 58, in make_requestg
resp, content = http.request(url, method, headers=headers, body=data)g
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 1597, in requestg
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)g
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 1345, in _requestg
(response, content) = self._conn_request(conn, request_uri, method, body, headers)g
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 1281, in _conn_requestg
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 1010, in connectg
sock.connect((, self.port))g
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 424, in connectg
self.__negotiatehttp(destpair[0], destpair[1])g
File "/usr/local/lib/python2.7/site-packages/httplib2/", line 390, in __negotiatehttpg
raise HTTPError((statuscode, statusline[2]))g
httplib2.socks.HTTPError: (403, 'Forbidden')

It seems to be available for free accounts as mine 1.

Hm, not sure, the 403 and the traceback do seem to indicate it's the proxy saying no... Perhaps it tries to connect to a different site, as well as Could you post some code for a minimal repro?

Thanks for the interest (:

It's pretty simple actually:

from import TwilioRestClient

client = TwilioRestClient(account, token)

recipient_number = "+221122222222"
sender_numeber = "+11123456789"
message = client.sms.messages.create(to=recipient_number, from_=sender_number,
                                    body="some message")

To make it work, one needs an API and token obtained through twilio's website.

@rodrigoaraujo: Welcome aboard the PA train!!

@rodrigoaraujo: I don't see any requests for twilio in the proxy logs, which suggests that the Twilio client does not honour the proxy settings. That means that Twilio won't work from a free account until the client is fixed to honour proxy settings. I have given your account full internet access for a week so you can try it out to see if it works. Let us know how it goes.

@glenn: Very cool. I didn't realize you guys had coded that ability in. Very cool!

One of our best early decisions was that all features are separate and that account types are just collections of features. That little bit of extra dev time has paid for itself many times over.

+1 for proper planning!!

@glenn Just tried and it worked flawlessly. Thanks for the effort.

When you say that the "Twilio client does not honour the proxy settings" you mean the TwilioRestClient? If so, and as it's available on GitHub, would it be possible to fix it?

Also, is the internet access feature available on the $5/month plan?

@a2j Thanks for the welcome and +2 for that! :D

Certainly it would be fixable if you have access to the source.

You can see a list of plan features here.

But the short answer is yes! Any paying account has full access. Originally all accounts had it, but there were people who were essentially anonymous creating accounts and using the PA platform to cause trouble for other sites. This would ultimately be problematic, so the PA staff responded with what they were forced to do out of necessity. And take care of the issue. Thus any unverified person that has an account must use the proxy and can only access the whitelist. The primary issue being as long as someone is paying for the service, they are identified at some level in the event they use the service to break laws and PA gets served by the court asking to identify the perpetrator(s).

Besides, you get a GOLD star with a paid, join the IN crowd...☺

@rodrigoaraujo Excellent. Yes, I mean the TwilioRestClient from GitHub, so it should be possible to fix it. However, there is a deep and long-standing bug in some of the Python url libraries related to SSL through a proxy that means that a fix might not be easy depending on the url library that TwilioRestClient uses. So a fix to the "homouring proxy settings" issue may just change which bug acts as a blocker. Full internet access is available on the $5 plan. We only block general internet access to accounts that are essentially anonymous and that have nothing to lose by abuse.