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

How to Fix: JavaScript fetch - Failed to execute 'json' on 'Response': body stream is locked

Error occurs when fetch request status is greater than 400, preventing JSON parsing.

Quick Answer: Use the `json()` method after checking if the response status is OK (200-299) or using the `ok` property to check the response status.

When fetching data from a server using JavaScript, it's common to encounter the 'body stream is locked' error. This occurs when the response status is greater than 400 and the browser is unable to parse the JSON content.

💡 Why You Are Getting This Error

  • [Cause]

🚀 How to Resolve This Issue

Method 1: Check Response Status

  1. Step 1: Verify the response status code is within the acceptable range (200-299). If not, you may need to handle errors accordingly.

Method 2: Use `json()` on Response Text

  1. Step 1: Parse the response text as JSON using the `json()` method.

💡 Conclusion

By following these methods, you should be able to resolve the 'body stream is locked' error when fetching JSON data using JavaScript and a response status greater than 400.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions