Next.js Discord

Discord Forum

Fetch failed when building the app

Answered
Arboreal ant posted this in #help-forum
Open in Discord
Arboreal antOP
Generating static pages (0/12)  [    ]
TypeError: fetch failed
    at node:internal/deps/undici/undici:12345:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async globalThis.fetch (C:\Users\...\frontend\.next\server\chunks\638.js:1:36415)
    at async p (C:\Users\...\frontend\.next\server\app\page.js:1:24795)
    at async m (C:\Users\...\frontend\.next\server\app\page.js:1:24901) {
  cause: AggregateError
      at internalConnectMultiple (node:net:1114:18)
      at afterConnectMultiple (node:net:1667:5)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'ECONNREFUSED',
    [errors]: [ [Error], [Error] ]
  }
}
i get that error when i do npm run build, the app works fine when i run it with npm run dev but when i build it, i get that error
Answered by Southern rough shrimp
export const dynamic = 'force-dynamic';
View full answer

12 Replies

Arboreal antOP
bump
Southern rough shrimp
Are you doing any web requests in any of your pages
it might trying to statically render that page
@Southern rough shrimp it might trying to statically render that page
Arboreal antOP
how can i stop that?
Southern rough shrimp
export const dynamic = 'force-dynamic';
Answer
@Southern rough shrimp export const dynamic = 'force-dynamic';
Arboreal antOP
in what file do i put that?
Southern rough shrimp
In the file you’re doing the fetch in
Specifically thenpage
Read the article and understand what it means
@Southern rough shrimp In the file you’re doing the fetch in
Arboreal antOP
doesnt it automatically make it dynamic if data is fetched?