PHP Errors

When your application is running, you may notice PHP errors within your application logs, or you may want to ensure your PHP scripts are not running indefinitely due to incomplete or stalled requests. This article explains how to configure appropriate timeout settings and memory limits to ensure the stability, security, and optimal performance of your application.

Memory Limit

The default PHP memory limit on Application Hosting is 128MB for all PHP versions. If your application exceeds this limit, you may see an error similar to the following in your application logs:

Detected 1047468200 Bytes of RAM

PHP memory_limit is 128M Bytes

To increase your application’s memory limit, create a .user.ini file in the application’s root directory and add the memory limit setting to the file. For example, if you want to increase the PHP memory limit to 256MB, add the following:

memory_limit = 256M

Increase Request Terminate Timeout

The request_terminate_timeout directive for FastCGI Process Manager (FPM) determines the maximum time a PHP script can run before the web server forcefully terminates it, regardless of whether the script has completed or not.

This is useful for preventing PHP scripts from running indefinitely, which can happen due to coding errors, infinite loops, or excessive processing times. By setting an appropriate request_terminate_timeout, you can prevent PHP processes from consuming excessive server resources and potentially affecting the overall performance and stability of the server.

To change the value of request_terminate_timeout:

  1. Create a file named fpm_custom.conf within the root directory of your repository and add the required value within it, for example (default unit is seconds):
  2. request_terminate_timeout = 120
  3. Push the changes to your Git repository.
  4. Within MyKinsta, select your Application > Processes > edit the Web process > update the Start command to include the fpm_custom.conf file, for example: heroku-php-apache2 -F fpm_custom.conf