Failed to fetch

JavaScript ErrorTypeErrorCommonLast updated: June 28, 2026Tested on:V8 Engine v11.3ECMAScript 2023June 2026

The browser failed to execute a fetch network request.

Failed to fetch Quick Fix⏱️ Est. Fix Time: 3–12 minutes

Usually happens because:

  • Server is offline
  • CORS header is missing
  • No internet connectivity

🔍 Quick Checklist:

📊 Where this usually happens (estimated occurrence)

Target server offline40%
CORS configuration blocks35%
Internet connection drop15%
SSL/TLS cert mismatch10%

What is Failed to fetch?

This TypeError is thrown by the browser's Fetch API when a network request fails to start or complete due to network outages, domain resolution failures, SSL configuration mismatches, or CORS blocks.

Common Causes

  • The client has lost internet connectivity.
  • The target server is offline or returned an invalid SSL/TLS certificate.
  • CORS policy blocks access to the external domain.
  • The destination URL has spelling typos.

Common Mistakes

  • Assuming fetch rejects promises on HTTP 404 or 500 status codes (fetch only rejects on physical network failures; status codes must be checked via response.ok).

How to Fix

1Check client connection state before starting queries.
2Verify server online status and check domain certificates.
3Configure appropriate CORS headers on the destination server.
4Always wrap fetch calls in try-catch blocks.

Framework-Specific Examples

Standard catch block monitoring network outages.

Catching Fetch Failures Example
async function loadData() {
  try {
    const res = await fetch('https://api.com/users');
    const users = await res.json();
  } catch (err) {
    console.log('Network lookup failed.');
  }
}

Server Configuration Examples

Node.js standard fetch behavior.

Node.js fetch equivalent Config
# Handled at client engine

Best Practices

  • Check `navigator.onLine` before executing heavy fetches.
  • Implement client-side fallback offline modes.

Frequently Asked Questions (FAQ)

Q: Why does fetch throw 'Failed to fetch' instead of an HTTP error code?

The Fetch API promise resolves successfully even if the server returns error statuses (like 404 or 500). It only rejects (throwing 'Failed to fetch') if the request cannot be completed due to DNS, network, CORS, or SSL failures.

Q: How do I check for internet connection?

You can check the browser's connectivity flag `navigator.onLine` or monitor events using `window.addEventListener('offline', ...)`.

Q: Can CORS cause 'Failed to fetch'?

Yes. If the destination server does not return the correct CORS headers, the browser blocks the response at the network layer, which is reported to the script as a generic 'Failed to fetch'TypeError.

Q: How do I debug SSL issues in fetch?

Inspect the browser's console or developer Network tab. It will specify if the request failed due to untrusted certificates or expired handshakes.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error