PHP max_input_time Explained: Configuration, Timeouts, and Best Practices
Introduction
The max_input_time directive defines the maximum amount of time PHP spends parsing input data from a client request. This includes processing POST data, uploaded files, and other request input before the PHP script begins executing.
Unlike max_execution_time, which limits how long a PHP script may run, max_input_time only applies while PHP is receiving and parsing request data.
This guide explains how max_input_time works, how to configure it, recommended values for different applications, and common timeout issues related to file uploads and large form submissions.
Test Environment
What Is max_input_time?
The max_input_time directive specifies the maximum number of seconds PHP spends reading and parsing input data from an HTTP request.
Example:
max_input_time = 60
With this configuration, PHP has 60 seconds to process incoming request data before the script begins execution.
If parsing the request takes longer than the configured limit, PHP terminates the request.
How max_input_time Works
A typical HTTP request follows this sequence:
The important point is that max_input_time applies before the PHP script starts running.
Check the Current Value
Run:
Example:
max_input_time => 60 => 60
Locate the Active php.ini File
Example:
Loaded Configuration File: /etc/php.ini
If your website uses PHP-FPM, ensure you edit the configuration file used by PHP-FPM.
Change max_input_time
Open the PHP configuration file.
Find:
max_input_time = 60
Example:
max_input_time = 300
Save the file.
Restart PHP-FPM
Apply the changes.
Verify:
Expected output:
Active: active (running)
Verify the Configuration
Run:
Or create a PHP file:
Search for:
max_input_time
max_input_time vs max_execution_time
These directives control different stages of request processing.
Example:
If the upload takes too long to reach PHP, max_input_time may be exceeded before the script even begins.
max_input_time and File Uploads
Large uploads are affected by several configuration directives working together:
Increasing only one directive may not resolve upload problems if another limit is reached first.
Recommended Values
Select a value appropriate for your application's upload patterns and expected network conditions.
Common Issues
Large Uploads Fail
Possible causes include:
max_input_time is too low.
upload_max_filesize is too small.
post_max_size is too small.
The web server has its own request timeout.
PHP-FPM has not been restarted.
Slow Network Connections
Users with slower internet connections may require more time to upload large files. Increasing max_input_time can help accommodate these scenarios when large uploads are expected.
Configuration Changes Do Not Apply
Check that:
The correct php.ini file was modified.
PHP-FPM has been restarted.
The updated value appears in phpinfo() or php -i.
Best Practices
Increase max_input_time only when necessary.
Configure upload_max_filesize and post_max_size consistently.
Verify web server timeout settings in addition to PHP configuration.
Restart PHP-FPM after changing configuration values.
Test large uploads under realistic conditions.
Conclusion
The max_input_time directive limits the amount of time PHP spends reading and parsing incoming request data before script execution begins. It plays an important role in applications that handle large file uploads or complex form submissions.
Because file uploads depend on multiple PHP and web server settings, troubleshooting upload issues should include reviewing max_input_time alongside upload_max_filesize, post_max_size, max_execution_time, and the web server's own request limits.
Explore More
› PHP max_execution_time Explained: Configuration, Timeouts, and Best Practices
› PHP opcache.max_accelerated_files Explained: Configuration, Performance, and Best Practices
› PHP opcache.validate_timestamps Explained: Configuration, Code Updates, and Best Practices
› PHP opcache.revalidate_freq Explained: Configuration, Performance, and Best Practices