ECONNRESET error in Next.js fetching

I have this Header.js, but sometimes there is an error on fetching the data.

import styles from './Header.module.scss'
import { createClient } from '@/prismicio'
import HeaderWrapper from '../HeaderWrapper/HeaderWrapper';

const Header = async () => {
    const client = createClient();
    const information = await client.getSingle("information");
    const menu = await client.getSingle("main_menu");

    return (
        <div className={styles.header}>
            {/* <pre>{JSON.stringify(, undefined, 2)}</pre> */}

            <HeaderWrapper information={information} menu={menu} />


export default Header

Here you have the error that I recevied:

I'm not sure why, but sometimes works, sometimes doesn't.

Let me know if you need more information about it.
Thanks for your help.

1 Like

and this is the error I have on my terminal when I want to try to run the websiteÑ

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11576:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: read ECONNRESET
      at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
      at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -4077,
    code: 'ECONNRESET',
    syscall: 'read'

Hey Jordi,

What version of Next.js are you using? We've seen some fetching issues in recent Next.js versions (around v13 specifically). Could you try updating to the latest version of Next.js and see if the error persists?


Hi @samlittlefair , thanks for your answer.

I'm using Netxtjs 14.

this is my package.json:

  "name": "XXX",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "slicemachine": "start-slicemachine"
  "dependencies": {
    "@prismicio/client": "^7.3.1",
    "@prismicio/next": "^1.5.0",
    "@prismicio/react": "^2.7.3",
    "eslint": "8.47.0",
    "eslint-config-next": "13.4.19",
    "framer-motion": "^10.16.1",
    "gsap": "^3.12.4",
    "next": "^14.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-router-dom": "^6.15.0",
    "sass": "^1.66.1"
  "devDependencies": {
    "@slicemachine/adapter-next": "^0.3.34",
    "slice-machine-ui": "^1.23.1"

Hey Jordi,

Given that you're seeing an ECONNRESET error, I suspect that the error is in your app or on your network. Are you getting the error locally or when you build the project in production?

If it's local, is it possible you have network configurations — such as a VPN or firewall — that could be causing problems?


I recently get a very similar error in a newly created project:

⨯ TypeError: fetch failed
    at async RootLayout (./src/app/layout.tsx:27:24)
Cause: Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
 ⨯ TypeError: fetch failed
    at async RootLayout (./src/app/layout.tsx:27:24)
digest: "1573418083"

I'm using "next": "14.1.4", and the newest versions of Prismic / Slicemachine.

I don't have any VPN or firewall configuration and the internet connection is stable. The error only appears locally. Any idea what could be the cause?

After several reloading it sometimes works - and then, the error appears again.

I'm getting Connection reset by peer - SSL_connect since a few days ago in our Production server and locally (development).

I imagine you need to update the SSL certificates, because they seem expired.

I have similar issue.

Hey @andre.lergier @wakematta @codyslexia,

  • Are you still having these issues?
  • Are they specifically "ECONNRESET" issues?
  • If you're not still having them, when did they stop?


Hey @samlittlefair

Sorry for the late response.
The error luckily disappeared without any code / network / deployment change on my side.

I believe it stopped around April 12.


1 Like