twilio-32007TwiliocriticalMedia Connection Failed
The media stream between Twilio and your endpoint could not be established, resulting in no audio.
What this error means
Root causes
Network connectivity issue between Twilio's media servers and your endpoint (firewall blocking RTP ports, NAT traversal failure)
Common
Incorrect or unreachable media endpoint URL/IP address configured in your TwiML or Twilio application settings
Common
Media endpoint server is down, not responding, or rejecting connections on the expected port
Common
Firewall or security group rules on your infrastructure blocking inbound RTP traffic (ports 10000-20000 or custom range)
Common
Media endpoint is listening on a different IP/port than what Twilio is attempting to connect to
Occasional
DNS resolution failure for the media endpoint hostname
Occasional
TLS/SSL certificate validation failure if using secure WebSocket connections
Occasional
Network timeout or latency exceeding acceptable thresholds for media stream establishment
Occasional
Misconfigured or missing codec parameters in the media stream negotiation
Rare
How to fix it
- 1
Verify Media Endpoint Availability
Confirm that your media endpoint server is running and accessible. Test connectivity by attempting to reach the endpoint URL/IP from a terminal using curl, telnet, or your language's HTTP client. Ensure the server is listening on the correct port and responding to connection attempts.
- 2
Check Network Firewall Rules
Review your firewall and security group configurations to ensure inbound RTP traffic is allowed. Twilio typically uses UDP ports in the range 10000-20000, but verify the specific port range for your configuration. Test by temporarily allowing all inbound traffic (in a non-production environment) to isolate firewall as the issue.
- 3
Validate Endpoint Configuration in TwiML
Review your TwiML or Twilio SDK code to ensure the media endpoint URL is correctly specified. Verify the URL includes the correct protocol (http/https/ws/wss), hostname/IP, port, and any required path. Cross-reference with your actual server configuration.
<!-- Correct example for WebSocket media endpoint --> <Connect> <Stream url="wss://your-domain.com:8080/media" /> </Connect> - 4
Test DNS Resolution
If using a hostname, verify DNS resolution is working correctly. Run nslookup or dig commands to confirm the hostname resolves to the expected IP address. Consider using IP addresses directly in staging to eliminate DNS as a variable.
- 5
Review Server Logs and Connection Attempts
Check your media endpoint server logs for connection attempts from Twilio. Look for connection refused, timeout, or authentication errors. Enable verbose logging on both Twilio (via debugger) and your media server to trace the failure point.
- 6
Verify NAT and Public IP Configuration
If your endpoint is behind NAT, ensure the public IP address and port forwarding are correctly configured. Twilio must be able to reach the public-facing address. Use tools like whatismyipaddress.com to confirm your public IP, and verify port forwarding rules on your router or cloud provider.
- 7
Check TLS/SSL Certificate (for Secure Endpoints)
If using wss:// (secure WebSocket), verify your SSL/TLS certificate is valid and trusted. Ensure the certificate's Common Name or SAN matches the hostname Twilio is connecting to. Test certificate validity with online tools like SSL Labs or by examining certificate details in your server configuration.
- 8
Review Twilio Call Logs and Diagnostics
Access Twilio's Console to review call logs for the failing session. Check the detailed call logs for timestamps and additional error context. Use Twilio's API to retrieve call metadata that may provide clues about where the connection failed in the media path.
- 9
Test with a Known-Good Media Endpoint
If available, test your TwiML/configuration with a publicly available media echo server or a different known-working endpoint. This isolates whether the issue is with Twilio's ability to establish media streams generally, or specifically with your endpoint.
- 10
Check Bandwidth and Network Conditions
Verify that adequate bandwidth is available and there are no network congestion issues between Twilio's infrastructure and your endpoint. Monitor network metrics like packet loss, jitter, and latency. Consider temporarily testing from a different network location to rule out ISP-level issues.
Prevention
To prevent twilio-32007 errors, implement comprehensive media endpoint monitoring with alerting for availability and responsiveness. Use redundant media servers with load balancing and failover capabilities. Maintain detailed documentation of your media endpoint configuration including IP addresses, ports, and protocol versions. Implement automated health checks that verify connectivity between your infrastructure and Twilio's media servers. Use IP whitelisting on your firewall to allow only Twilio's known media server IP ranges. Regularly test your media endpoints in staging environments before deploying to production, and maintain a runbook for quick diagnosis and resolution.
Debugging this right now?
Sherlock diagnoses twilio-32007 automatically. Just ask in Slack and get an instant root-cause analysis.
Add to Slack — Free