Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Fetch API request timeout?

Fetch API request timeout default value and how to set it.

Quick Answer: "fetch" options object has a "timeout" property. Set it to a number (in milliseconds) or Infinity for indefinite timeout.

The Fetch API request timeout is set to the value of the `timeout` property in the options object. By default, it is set to a very short period of time, usually around 2 seconds (2000 milliseconds), but this can be adjusted.

🔍 Why This Happens

  • [Cause]

🛠️ Step-by-Step Verified Fixes

Method 1: Setting a timeout value

  1. Step 1: Add the `timeout` property to your fetch options object and set its value to the desired time in milliseconds.

Method 2: Setting a timeout value for indefinite

  1. Step 1: Add the `timeout` property to your fetch options object and set its value to `-1` (or `Infinity`) for an indefinite timeout.

💡 Conclusion

By following these steps, you can set a custom timeout value for your Fetch API request and avoid the default 2-second timeout.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions