PlayFramework 2.4.6 error 413 Request Entity Too Large
For those who are facing issue with Play Framework 2.6.x see documentation at https://www.playframework.com/documentation/2.6.x/ScalaBodyParsers
Max content length Text based body parsers (such as text, json, xml or formUrlEncoded) use a max content length because they have to load all the content into memory. By default, the maximum content length that they will parse is 100KB. It can be overridden by specifying the play.http.parser.maxMemoryBuffer property in application.conf:
add following in application.conf:
play.http.parser.maxMemoryBuffer = 5MB
Solved the problem with this:
play.http.parser.maxDiskBuffer = 100MB
parsers.anyContent.maxLength = 100MB
I was having the same problem sending a large form and play.http.parser.maxMemoryBuffer=4MB
solved it.
See this documentation about the memory and disk buffers Play uses: https://www.playframework.com/documentation/2.4.x/ScalaBodyParsers#Max-content-length
Text based body parsers (such as text, json, xml or formUrlEncoded) use a max content length because they have to load all the content into memory. By default, the maximum content length that they will parse is 100KB. It can be overridden by specifying the
play.http.parser.maxMemoryBuffer
property in application.conf:
play.http.parser.maxMemoryBuffer=128K
For parsers that buffer content on disk, such as the raw parser or multipart/form-data, the maximum content length is specified using the
play.http.parser.maxDiskBuffer
property, it defaults to 10MB. The multipart/form-data parser also enforces the text max length property for the aggregate of the data fields.
So, since you're trying to uploading a multipart file, you'll need to increase the play.http.parser.maxDiskBuffer
to something >18MB.
So, adding this to your application.conf should fix it:
play.http.parser.maxDiskBuffer=100MB