I am trying to build a nextjs app. It runs fine on npm run dev but gives this error when I run npm run build
> Build error occurred
FetchError: request to http://localhost:4001/graphql failed, reason: connect ECONNREFUSED 127.0.0.1:4001
at ClientRequest.<anonymous> (/Users/naweddiwan/Desktop/codinqQuest/next-saas-starter/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (events.js:400:28)
at Socket.socketErrorListener (_http_client.js:475:9)
at Socket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
type: 'system',
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED'
}
Can somehelp me, what can be causing this error.