WebRTC Connection Errors — ICE Failed, STUN/TURN, and Peer Connection Issues
Errorweb development
Overview
Fix WebRTC connection errors including ICE connection failed, STUN/TURN server issues, NAT traversal failures, and peer-to-peer video call disconnections.
Key Details
- WebRTC enables peer-to-peer audio, video, and data communication directly between browsers
- ICE (Interactive Connectivity Establishment) finds the best path between peers
- STUN servers help discover your public IP; TURN servers relay traffic when direct connection fails
- Corporate firewalls and strict NATs can block WebRTC peer connections
- ICE connection state progression: new > checking > connected > completed (or failed/disconnected)
Common Causes
- Both peers behind symmetric NAT without a TURN relay server
- Corporate firewall blocking UDP traffic on non-standard ports
- STUN server unreachable or returning incorrect candidate information
- TURN server credentials expired or server at capacity
- Browser VPN extension routing traffic through a path that breaks WebRTC
Steps
- 1Check WebRTC connection state: monitor RTCPeerConnection.iceConnectionState in DevTools console
- 2Verify STUN/TURN servers: test with trickle-ice.nicedandy.com to see if candidates are gathered
- 3Ensure a TURN server is configured for fallback: ICEServer config should include both STUN and TURN
- 4Allow UDP traffic: WebRTC prefers UDP; ensure firewall allows UDP on ports used by TURN (typically 443 or 3478)
- 5Try TURN over TCP/443 as a fallback for restrictive firewalls (mimics HTTPS traffic)
- 6Disable browser VPN extensions that may interfere with WebRTC ICE candidate gathering
Tags
webrtcicestunturnpeer-connection
More in Web Development
browser-cors-error-explainedBrowser CORS Error Explained — Cross-Origin Request Blocked
Warningbrowser-websocket-errorsBrowser WebSocket Errors — Connection Failed, Closed & Protocol Errors
Warningbrowser-indexeddb-errorsBrowser IndexedDB Errors — Quota Exceeded, Blocked & Corruption
Warningbrowser-localstorage-quota-exceededBrowser localStorage Quota Exceeded — Storage Limit & Alternatives
Warningbrowser-service-worker-errorsBrowser Service Worker Errors — Registration, Cache & Update Failures
Warningbrowser-webgl-context-lostBrowser WebGL Context Lost — GPU Rendering Failure in Browser
WarningFrequently Asked Questions
STUN helps discover your public IP for direct peer connection (free, low bandwidth). TURN relays all traffic through the server when direct connection fails (expensive, high bandwidth). Most calls use STUN; TURN is the fallback.