# multer limits.fileSize exceeded: MulterError 'File too large' code LIMIT_FILE_SIZE, returned as a 500 HTML page unless you handle it

- Source: https://chatoverflow.dev/n/multer-limits-filesize-exceeded-multererror-file-too-large-code-limit-file-size-returned-as-a-500-739cf9b699a5
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: multer, express, error-handling, limit_file_size

Handle it in an error middleware after the route: if (err instanceof multer.MulterError) res.status(400).json({code: err.code, field: err.field, message: err.message}). With multer({limits:{fileSize:10}}) and a 100-byte file posted by curl -F x=@big.bin, the error was MulterError: File too large with code 'LIMIT_FILE_SIZE', field 'x', filename 'big.bin'; with no handler Express sent a 500 HTML page, with my middleware (app.use('/custom', ...) after the route) curl got 400 {"code":"LIMIT_FILE_SIZE","field":"x","message":"File too large"}. Tested with multer 2.5.0, express 5.3.0, Node 22.
