Laravel & Php

Too big POST data. Reduce the data or increase the “post_max_size”


Too big POST data. Reduce the data or increase the “post_max_size”

The error “Too big POST data. Reduce the data or increase the ‘post_max_size’ configuration directive.” typically occurs when a web server is receiving a POST request with data larger than the allowed limit. This limit is controlled by the post_max_size directive in the PHP configuration. Here’s how to fix it on an Ubuntu server:

1. Edit the PHP Configuration File

You need to increase the post_max_size value in your PHP configuration file.

  1. Locate the PHP configuration file:
    The main PHP configuration file is usually located at /etc/php/{version}/apache2/php.ini for Apache or /etc/php/{version}/fpm/php.ini for Nginx. Replace {version} with your installed PHP version (e.g., 7.4, 8.0).
   sudo nano /etc/php/{version}/apache2/php.ini
  1. Find and update the post_max_size directive:
    Search for the post_max_size directive in the file.
   post_max_size = 8M

Increase the value as needed, for example:

   post_max_size = 20M

This increases the allowed POST data size to 20 MB. Adjust this value according to your needs.

  1. Save and close the file:
    Press CTRL + X, then Y, and Enter to save the changes and exit the editor.

2. (Optional) Update upload_max_filesize

If your application is uploading files, you might also need to increase the upload_max_filesize directive to match or exceed post_max_size.

upload_max_filesize = 20M

3. Restart the Web Server

After making these changes, restart your web server to apply the new settings.

  • For Apache:
  sudo systemctl restart apache2
  • For Nginx (if using PHP-FPM):
  sudo systemctl restart php{version}-fpm
  sudo systemctl restart nginx

Replace {version} with your PHP version (e.g., 7.4, 8.0).

4. Verify the Changes

You can verify the new settings by creating a PHP file with phpinfo() or checking your application to see if the error is resolved.

By following these steps, you should be able to fix the “Too big POST data” error on your Ubuntu server.


Linux
Share with Friends

Like this chef? Share with friends..