RTCPeerConnection: icecandidateerror event

Baseline 2026
Newly available

Since April 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The icecandidateerror event is sent to an RTCPeerConnection if an error occurs while performing ICE negotiation through a STUN or TURN server.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("icecandidateerror", (event) => { })

onicecandidateerror = (event) => { }

Event type

An RTCPeerConnectionIceErrorEvent. Inherits from Event.

Event RTCPeerConnectionIceErrorEvent

Examples

Basic usage

The following example establishes a handler for icecandidateerror events that occur on the RTCPeerConnection pc. This handler looks specifically for 701 errors that indicate that candidates couldn't reach the STUN or TURN server.

When this happens, the server URL and the error message are passed to a function called reportConnectFail() to log or output the connection failure.

js
pc.addEventListener("icecandidateerror", (event) => {
  if (event.errorCode === 701) {
    reportConnectFail(event.url, event.errorText);
  }
});

Note that if multiple STUN and/or TURN servers are provided when creating the connection, this error may happen more than once, if more than one of those servers fails. Each provided server is tried until a connection is established.

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcpeerconnection-onicecandidateerror

Browser compatibility

See also