3

next/image cause the server down of error 502 gateway error.

I check from the devtool network, it go fetch the third party (themoviedb) api. Those images cannot be load correctly but it work fine in my local machine in nextJs build in image component.

I tried to use pure html tag to load those image, this 502 gateway error is solved.

Is any clue that why next/image are causing my DO server 502 gateway error?

Wilker
  • 551
  • 2
  • 6
  • 21

3 Answers3

1

I had this same problem, and it was resolved when I reduced the image sizes down to 2000px x 2000px (or below). I also reduced the resolution to 90 at the same time, but I suspect the overall size was the issue. My files were PNGs, in case that's helpful.

emersonthis
  • 32,822
  • 59
  • 210
  • 375
0

For production, i installed 'sharp' package which is strongly recommended. Run yarn add sharp or npm i sharp, and Next.js will use it automatically for Image Optimization. https://nextjs.org/docs/messages/sharp-missing-in-production

ptaha
  • 1
  • 1
0

I ran into this same 502 gateway error with images when deploying a next.js app to AWS EBS (beanstalk). In my case the issue was that the server was under provisioned. Bumping it up to a larger instance size fixed it for me.

(if it helps anyone I moved from a t4g.nano to t4g.micro instance size)

Armin Sadeghi
  • 766
  • 12
  • 19