Strapi is restarting

[details=“System Information”]

  • Strapi Version: v4.25.2
  • Operating System: Ubuntu
  • Database: Postgres
  • Node Version: v20.10.0
  • Yarn Version: 1.22.22

When I upload an image too large, Strapi responds with a ‘502 Bad Gateway’ error, and the server restarts. I must upload files directly to Strapi rather than using S3 or Cloudinary. Even though I have configured the plugin.ts and middleware.ts files, the issue persists."

plugin.ts

middleware.ts

How to fix this?
Can you please provide a proper solution?

Thanks in advance