Resolving HTTP Error 413 - Request entity too large

This error has been reported by a few users to me regarding application which seats on Tomcat fronted by Apache and configured to use Apache Tomcat Connector mod_jk

Request Entity Too Large
The requested resource /testapp/ does not allow request data
with GET requests, or the amount of data provided
in the request exceeds the capacity limit.

The mod_jk.log file shows

[error] ajp_marshal_into_msgb::jk_ajp_common.c (415): failed appending the header value
[info] ajp_service::jk_ajp_common.c (1927): Creating AJP message failed, without recovery
[info] jk_handler::mod_jk.c (2270): Aborting connection for worker=worker1

The only solution I found is to increase the maximum AJP packet size. I added the line worker. worker1.max_packet_size=65536 to the file and the line packetSize="65536" to the AJP Connector element in Tomcat’s server.xml




hari said...

Thanks. I was thinking where to put the changes on tomcat end and not getting enough info on that.

Works now!

But I would like to know why it occurs in the first end. In my case, some of my users are not affected. But others do get the "entity" error. Don't understand why it should be like that in the same network.

Anonymous said...


Thanks very much for your solution, worked very well. I tried it out first only with packetSize in server.xml, which doesn't work.


Anonymous said...

Well, sonofagun -- thanks for posting this! We've wasted a few days trying to track this thing down.

Sometimes users would get this, and sometimes it would work fine...for the exact same POST request! We thought it was a server-load-related issue.

Anonymous said...

For those who come upon this page later....

It all sounded so simple and straightforward, but it ended up involving a few days of troubleshooting.

It turns out the servers.xml->pageSize parameter conflicts with the request.useSecret and request.secret parameters of the Connector. Once those were commented out, the change in packet size worked fine.

For what it's worth.

Anonymous said...

Thanks a lot for posting this. saved a lot of time!

Anonymous said...

The reason why this occurs for some users is due to the cookie size. The application might set lot of cookies for the user and if the length exceeds the default packet size limit of 8k (cooike size + other http header values), the user would see this problem.

Anonymous said...

I have no idea what you guys are talking about (not tech savvy), but a simple solution for me when having this issue, was to delete any cookies already saved in your browser relating to the particular site you were accessing.

Unknown said...

Thanks, solved our problem too! We were running into this because of an overly long header due to SPNEGO/Kerberos auth being configured.

KLashbrook said...

If users belong to many AD security groups, their Kerberos ticket will be very large. That causes the Auth header to exceed the max.

That also explains how/why only some users may experience the error, while others have no problems.

Check how many AD groups they are members of.

Anonymous said...

Thanks! For me, this error was the cookie plus request size. I removed cookies and voila! If this continues I will consider increasing limits, but this has only happened to me and only in one browser, so I am content to leave as-is unless this becomes a bigger issue.