internal server error when deploying to DigitalOcean

When entering some specific pages in my site, the server gets an error and shuts down. Why is this happening? I run it locally - everything works I run it on vercel - everything works But on DigitalOcean it breaks I have a loop of errors of this type:
TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at async invokeRequest (/home/dor/project_name/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:17:12)
at async invokeRender (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:254:29)
at async handleRequest (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:447:24)
at async requestHandler (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:464:13)
at async Server.<anonymous> (/home/dor/project_name/node_modules/next/dist/server/lib/start-server.js:117:13) {
cause: SocketError: other side closed
at Socket.onSocketEnd (/home/dor/project_name/node_modules/next/dist/compiled/undici/index.js:1:63301)
at Socket.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'UND_ERR_SOCKET',
socket: {
localAddress: '::1',
localPort: 58042,
remoteAddress: '::1',
remotePort: 45019,
remoteFamily: 'IPv6',
timeout: undefined,
bytesWritten: 5873,
bytesRead: 12394
}
}
}
TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at async invokeRequest (/home/dor/project_name/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:17:12)
at async invokeRender (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:254:29)
at async handleRequest (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:447:24)
at async requestHandler (/home/dor/project_name/node_modules/next/dist/server/lib/router-server.js:464:13)
at async Server.<anonymous> (/home/dor/project_name/node_modules/next/dist/server/lib/start-server.js:117:13) {
cause: SocketError: other side closed
at Socket.onSocketEnd (/home/dor/project_name/node_modules/next/dist/compiled/undici/index.js:1:63301)
at Socket.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'UND_ERR_SOCKET',
socket: {
localAddress: '::1',
localPort: 58042,
remoteAddress: '::1',
remotePort: 45019,
remoteFamily: 'IPv6',
timeout: undefined,
bytesWritten: 5873,
bytesRead: 12394
}
}
}
`
7 Replies
Dor
DorOP7mo ago
Ok, this only happens when I try to display an image on a page that is NOT from the same origin URL But why does the server break though? I already configured my NextJS config: ``` images: { remotePatterns: [ { protocol: "https", hostname: "", }, { protocol: "http", hostname: "", }, ], },
Dor
DorOP7mo ago
This might be a next js version issue. Trying to follow this: https://medium.com/@pawanjotkaurbaweja/solved-typeerror-fetch-failed-4f7d304c0c68 Will update if it works
Medium
Solved!!!!!!!! — TypeError: fetch failed
at node:internal/deps/undici/undici:12345:11
Dor
DorOP7mo ago
after spending an entire day digging I gave up and went back to vercel what's the right way to allow loading images from any website then? keep in mind that this works both locally and on Vercel, and it works on DigitalOcean too but only on DigitalOcean the server randomly collapse
michaeldrotar
michaeldrotar7mo ago
The hostname must be filled in The docs mention the other parts are optional and will default to ** but hostname is the most important part to list domains other than the current app's domain that you're optimizing images from (And ideally, all the fields should be filled in to be the most secure) https://nextjs.org/docs/app/api-reference/components/image#remotepatterns (There might be another issue cause I'm surprised it'd work on Vercel this way, but that's the most glaring one. You can also reference the deprecated domains config for more context.) I think the image format detection is more about new formats that aren't widely supported. Webp still doesn't work in IE and there might have been others when this feature was developed. Plus whatever the next hot new image format will be. Can find more info: https://nextjs.org/docs/app/building-your-application/optimizing/images
Dor
DorOP7mo ago
Ok I created a droplet on digital ocean again, but the problem persists. I fixed the remoetPatterns according to the next js docs. Why is this error happening? This is so random.
TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async invokeRequest (/home/dor/unpaack/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:17:12)
at async invokeRender (/home/dor/unpaack/node_modules/next/dist/server/lib/router-server.js:254:29)
at async requestHandler (/home/dor/unpaack/node_modules/next/dist/server/lib/router-server.js:475:24)
at async Server.<anonymous> (/home/dor/unpaack/node_modules/next/dist/server/lib/start-server.js:117:13) {
cause: Error: connect ECONNREFUSED ::1:36529
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 36529
}
}
TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async invokeRequest (/home/dor/unpaack/node_modules/next/dist/server/lib/server-ipc/invoke-request.js:17:12)
at async invokeRender (/home/dor/unpaack/node_modules/next/dist/server/lib/router-server.js:254:29)
at async requestHandler (/home/dor/unpaack/node_modules/next/dist/server/lib/router-server.js:475:24)
at async Server.<anonymous> (/home/dor/unpaack/node_modules/next/dist/server/lib/start-server.js:117:13) {
cause: Error: connect ECONNREFUSED ::1:36529
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 36529
}
}
I have a website where users can upload images and I'm using cloudinary as my provider, which later I display with Image component from Next js When I enter some pages with some photos, the server collapse giving me the error above I guess, but I'm not attempting to make any connection I'm just trying to view a webpage
Dor
DorOP7mo ago
I'm not doing anything goofy :theowat: And it works perefctly when hosted on Vercel - https://unpaack.com Would you be kind to inspect this live with me?
Unpaack
Unpaack is where you discover the products used by the people you follow
Dor
DorOP7mo ago
i'm doomed
Want results from more Discord servers?
Add your server