Back to Error Center

404 Not Found

Error Message

404 NOT_FOUND

Cause

The requested URL doesn't match any defined route, or the resource (model) was not found.

Solution

Check the URL for typos. Run php artisan route:list. If using route model binding, ensure the record exists. Check for soft-deleted models.

Code Example

Fix
// Check routes
php artisan route:list --path=posts

// Route model binding throws 404 for missing models
Route::get('/posts/{post}', [PostController::class, 'show']);
// If Post with ID doesn\'t exist, returns 404

// Custom 404 page
// resources/views/errors/404.blade.php

// Including soft-deleted models
Route::get('/posts/{post}', [PostController::class, 'show'])
    ->withTrashed();

Debugging Steps

  1. Run php artisan route:list to check defined routes
  2. Verify the URL matches a route pattern
  3. Check if the resource exists in the database
  4. Check if soft deletes are hiding the record
  5. Verify the route file is loaded

Prevention

Always define routes before accessing URLs. Use route names instead of hardcoded URLs. Handle 404 errors gracefully.