# Illuminate\Queue\MaxAttemptsExceededException: App\Jobs\ProcessVideo has been attempted too many times or run too long. The job may have previously timed out.

- **ID:** `php/laravel-queue-worker-timeout`
- **Domain:** php
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A queued job has exceeded the maximum number of attempts (max_attempts) or the job's execution time exceeded the timeout setting (retry_after), causing the worker to mark it as failed after repeated retries.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| laravel/framework:10.0.0 | active | — | — |
| laravel/framework:11.0.0 | active | — | — |

## Workarounds

1. **Inspect the failed_jobs table to retrieve the exception message: 'DB::table('failed_jobs')->where('queue', 'default')->get();' then fix the underlying issue (e.g., add error handling in the job's handle() method).** (90% success)
   ```
   Inspect the failed_jobs table to retrieve the exception message: 'DB::table('failed_jobs')->where('queue', 'default')->get();' then fix the underlying issue (e.g., add error handling in the job's handle() method).
   ```
2. **Increase the job's timeout and retry_after settings appropriately: in the job class, set 'public $timeout = 120;' and in config/queue.php set 'retry_after' => 120, but ensure the job logic is optimized to complete within that window.** (85% success)
   ```
   Increase the job's timeout and retry_after settings appropriately: in the job class, set 'public $timeout = 120;' and in config/queue.php set 'retry_after' => 120, but ensure the job logic is optimized to complete within that window.
   ```
3. **If the job is recoverable, manually requeue it using: 'php artisan queue:retry all' or specifically 'php artisan queue:retry <job-id>' after fixing the underlying bug.** (80% success)
   ```
   If the job is recoverable, manually requeue it using: 'php artisan queue:retry all' or specifically 'php artisan queue:retry <job-id>' after fixing the underlying bug.
   ```

## Dead Ends

- **** — Simply increasing the $tries property on the job class to a very high number (e.g., 100) without addressing the underlying timeout or error condition causes the job to keep retrying indefinitely, consuming queue resources and delaying other jobs. (80% fail)
- **** — Setting retry_after to an extremely high value in config/queue.php (e.g., 3600 seconds) prevents the job from being retried quickly, but if the job is genuinely stuck (e.g., due to an infinite loop), it will still hold the worker slot for too long. (60% fail)
- **** — Restarting the queue worker with 'php artisan queue:restart' resets the worker but does not clear the failed job status; the job will still be marked as failed in the jobs table and won't be re-executed automatically. (90% fail)
