The Twilio REST API is an HTTP-based API that requires secure connections over the public internet. Use these tools and techniques as a companion guide when configuring your environment and troubleshooting connection issues.
Twilio Status Page
If you suspect there is an issue with the Twilio REST API, be sure to check our status page for any platform-wide notices.
Debugging in the Helper Libraries
To assist with debugging, the Twilio helper libraries allow you to access the underlying request and response objects, including all the headers. This capability is built into the default HTTP client that ships with the libraries.
For example, to track down the source of latency, you can retrieve the custom Twilio header Twilio-Request-Duration to see how long in seconds the request took to process on our platform.
Here’s an example using our PHP helper library:
$sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$token = 'your_auth_token';
$client = new Client($sid, $token);
$message = $client->messages->create("+14158675309", array(
'From' => "+14258675310",
'Body' => 'Ahoy!'
/* Retrieve the last response from the HTTP client and inspect the Twilio-Request-Duration header */
If your request took much longer than the Twilio-Request-Duration header reported, there is likely a delay in your local network or your ISP is having issues.
Enable SSL/TLS Debugging
The Twilio REST API requires secure connections. When debugging SSL/TLS errors, you may need to get lower-level details from your HTTP client, if supported, to fully diagnose and resolve the issue.
Here is an example of enabling low-level debugging for Java: Debugging SSL/TLS Connections.
Diagnostic Tools and Utilities
There are many different tools and utilities you can use to diagnose connection issues. Here are some suggestions.
Note: The specific IP addresses in your output may be different than the examples below due to dynamic IP assignment within our cloud infrastructure.
Use ping networking utility to verify host reachability at the IP layer. If the ping fails or times out, your network connection may not have access to the public internet.
$ ping api.twilio.com
PING prod-api-us1-308668521.us-east-1.elb.amazonaws.com (220.127.116.11): 56 data bytes
64 bytes from 18.104.22.168: icmp_seq=0 ttl=253 time=165.123 ms
64 bytes from 22.214.171.124: icmp_seq=1 ttl=253 time=72.240 ms
64 bytes from 126.96.36.199: icmp_seq=2 ttl=253 time=90.751 ms
Use dig DNS query tool to troubleshoot DNS resolution. If you see status: NXDOMAIN in the response, there is likely a problem with your DNS provider.
$ dig api.twilio.com
; <<>> DiG 9.8.3-P1 <<>> api.twilio.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51922
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;api.twilio.com. IN A
;; ANSWER SECTION:
api.twilio.com. 2 IN CNAME prod-api-us1-308668521.us-east-1.elb.amazonaws.com.
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 188.8.131.52
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 184.108.40.206
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 220.127.116.11
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 18.104.22.168
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 22.214.171.124
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 126.96.36.199
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 188.8.131.52
prod-api-us1-308668521.us-east-1.elb.amazonaws.com. 5 IN A 184.108.40.206
;; Query time: 86 msec
;; SERVER: 192.168.208.1#53(192.168.208.1)
;; WHEN: Tue Jul 17 17:41:17 2018
;; MSG SIZE rcvd: 221
Use openssl to troubleshoot SSL/TLS related issues. If you receive an error, check the specific error code to determine the underlying issue. Be sure your openssl library is up to date and that you are referencing the correct location of your local trust store to verify our certificate.
$ openssl s_client -connect api.twilio.com:443 -quiet -CAfile cacert.pem
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte RSA CA 2018
depth=0 C = US, ST = California, L = San Francisco, O = "Twilio, Inc.", CN = *.twilio.com
Use curl as a general purpose tool for testing connectivity to the REST API. If you encounter an error, check the specific error code to determine the underlying issue.
$ curl https://api.twilio.com/ -v
* Trying 220.127.116.11...
* Connected to api.twilio.com (18.104.22.168) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.twilio.com
* Server certificate: thawte SSL CA - G2
* Server certificate: thawte Primary Root CA
> GET / HTTP/1.1
> Host: api.twilio.com
> User-Agent: curl/7.43.0
> Accept: */*
< HTTP/1.1 200 OK
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since
< Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag
< Content-Type: application/xml
< Date: Wed, 18 Jul 2018 01:11:48 GMT
< Strict-Transport-Security: max-age=15768000
< Twilio-Request-Duration: 0.001
< Twilio-Request-Id: RQ09370f289cef4fc7bec3e605a68be499
< X-Powered-By: AT-5000
< X-Shenanigans: none
< Content-Length: 254
< Connection: keep-alive
Use Fiddler as a multipurpose web debugging proxy to intercept and inspect requests while running your application. This can be useful for capturing issues that are intermittent or don't reveal themselves via the other tools and utilities.
Twilio Customer Support
For additional assistance diagnosing connection issues to our REST API, please contact Twilio Customer Support.