docs.rodeo

MDN Web Docs mirror

Network Error Logging

{{HTTPSidebar}} {{SeeCompatTable}} 

Network Error Logging is a mechanism that can be configured via the {{HTTPHeader("NEL")}}  HTTP response header. This experimental header allows websites and applications to opt-in to receive reports about failed (and, if desired, successful) network fetches from supporting browsers.

Reports are sent to a reporting group defined within a {{HTTPHeader("Report-To")}}  header.

Usage

Web applications opt in to this behavior with the NEL header, which is a JSON-encoded object:

NEL: { "report_to": "nel",
       "max_age": 31556952 }

An origin considered secure by the browser is required.

The following object keys can be specified in the NEL header:

The reporting group referenced above is defined in the usual manner within the {{HTTPHeader("Report-To")}}  header, for example:

Report-To: { "group": "nel",
             "max_age": 31556952,
             "endpoints": [
              { "url": "https://example.com/csp-reports" }
             ]
           }

Error reports

In these examples, the reporting API response content is shown. The top-level "body" key contains the network error report.

HTTP 400 (Bad Request) response

{
  "age": 20,
  "type": "network-error",
  "url": "https://example.com/previous-page",
  "body": {
    "elapsed_time": 338,
    "method": "POST",
    "phase": "application",
    "protocol": "http/1.1",
    "referrer": "https://example.com/previous-page",
    "sampling_fraction": 1,
    "server_ip": "192.0.2.172",
    "status_code": 400,
    "type": "http.error",
    "url": "https://example.com/bad-request"
  }
}

DNS name not resolved

Note that the phase is set to dns in this report and no server_ip is available to include.

{
  "age": 20,
  "type": "network-error",
  "url": "https://example.com/previous-page",
  "body": {
    "elapsed_time": 18,
    "method": "POST",
    "phase": "dns",
    "protocol": "http/1.1",
    "referrer": "https://example.com/previous-page",
    "sampling_fraction": 1,
    "server_ip": "",
    "status_code": 0,
    "type": "dns.name_not_resolved",
    "url": "https://example-host.com/"
  }
}

The type of the network error may be one of the following pre-defined values from the specification, but browsers can add and send their own error types:

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN