Home » Errors » How to Fix Maximum Execution Time of 30 Seconds Exceeded in Laravel

How to Fix Maximum Execution Time of 30 Seconds Exceeded in Laravel

If you use Laravel jobs, you can meet an error with the message “Maximum execution time of 30 seconds exceeded”. This means that the job will be stopped after 30 seconds of execution.

Laravel jobs have a timeout for execution set to 30 seconds by default. This value is the same as the default value of the max_execution_time PHP variable. In this article I will explain how to solve this error using different methods.

How to Fix This Error in Laravel

First, check the max_execution_time variable in the php.ini file for CLI scripts. Open the /etc/php/8.1/cli/php.ini file and find the max_execution_time directive:

This variable must contain 0 by default. It means that CLI scripts have no limits to execution. If it contains any other value, change it to zero.

1. Fix queue class

You can add the $timeout variable to a job class. Just add it after all other variables:

public $timeout = 0;

After this you can rerun your job and it will be executed normally.

2. Fix queue worker

If you don’t want to modify a job class, you can set the timeout globally for the queue worker. Just use the –timeout option with the value 0. For example:

php artisan queue:work --timeout 0

This command will also execute jobs without the timeout.

Wrapping Up

In this article I have explained how to fix the error “Maximum execution time of 30 seconds exceeded” in Laravel. It is very simple. You can read more about Laravel Jobs in this article. If you have any questions, use the comment field below.

Your Reaction

3 thoughts on “How to Fix Maximum Execution Time of 30 Seconds Exceeded in Laravel”

  1. Great goods from you, man. I have understand your stuff previous to and you
    are just extremely excellent. I actually like what you’ve acquired here, really like
    what you are stating and the way in which you say it. You make
    it enjoyable and you still take care of to keep it
    wise. I can’t wait to read much more from you. This is really a tremendous site.

  2. I am really loving the theme/design of your weblog.

    Do you ever run into any browser compatibility issues? A couple of my blog visitors
    have complained about my blog not operating correctly in Explorer but
    looks great in Firefox. Do you have any suggestions to help fix this problem?

    • This site have a few issues with colors in Internet Explorer. The developers of the template I’m using don’t want to adapt it for IE, and they are right because Microsoft ended support for this browser in 2022 for most editions of Windows.


Leave a Comment