'Bad Request' or 'Request Header Too Large' Error When Editing Entries in GravityView
If you're seeing errors like these when editing entries in GravityView:
- Request Header Fields Too Large
- Size of a request header field exceeds server limit
- Size of the request headers is too long
- 400 Bad Request
- 431 Request Header Fields Too Large
- 413 Request Entity Too Large
...the issue is almost always caused by cookies exceeding your server's header size limit.
Common Cause: Nested Forms Session Cookies
The most common cause is the gpnf_form_session_... cookies generated by Gravity Perks Nested Forms. These session cookies preserve child entry data if a user refreshes the page, but they can grow quite large with complex forms and accumulate as you navigate between entries.
Solutions
Option 1: Disable Nested Forms Sessions (Recommended)
If you don't need Nested Forms to preserve data after page refreshes, you can disable the session functionality using the Disable Sessions snippet from Gravity Wiz:
<?php
/**
* Gravity Perks // Nested Forms // Disable Sessions
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_action( 'wp_ajax_gpnf_session', 'gw_gpnf_disable_session', 9 );
add_action( 'wp_ajax_nopriv_gpnf_session', 'gw_gpnf_disable_session', 9 );
function gw_gpnf_disable_session() {
remove_action( 'wp_ajax_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
remove_action( 'wp_ajax_nopriv_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
$session = new GPNF_Session( rgpost( 'form_id' ) );
$session->delete_cookie();
}
add_filter( 'gpnf_can_user_edit_entry', function( $can_user_edit_entry, $entry, $current_user ) {
if ( ! $current_user && (int) gform_get_meta( $entry['id'], GPNF_Entry::ENTRY_PARENT_KEY ) === 0 ) {
$can_user_edit_entry = true;
}
return $can_user_edit_entry;
}, 10, 3 );
If you need help implementing this snippet, contact Gravity Wiz support - they provide assistance for their products even when used within GravityView.
Option 2: Increase Server Header Size Limits
You can increase the maximum allowed header size on your server:
Apache: Add to your .htaccess or server configuration:
LimitRequestFieldSize 32768
Nginx: Add to your server block:
large_client_header_buffers 4 32k;
After making changes, restart your web server. Note: this allows larger cookies but doesn't reduce their size.
Option 3: Clear Browser Cookies (Temporary Fix)
Clearing cookies for your site will resolve the immediate error, but it will return as you continue using nested forms. This is useful for quickly getting back to work while implementing a permanent solution.
Other Potential Causes
While Nested Forms is the most common cause, large headers can also result from:
- Too many cookies from various plugins
- Very long authentication tokens
- Other plugins storing data in cookies
If you're not using Nested Forms and still experiencing this error, try disabling plugins one by one to identify the culprit, or contact your hosting provider to increase header limits.