W3docs

Laravel says "Route not defined"

There could be several reasons why you are seeing this error message in Laravel.

There could be several reasons why you are seeing this error message in Laravel. Here are some possible causes:

  1. You have not defined the route in your route file. Make sure that you have defined the route in the correct route file (either web.php or api.php) and that you have specified the correct HTTP verb (GET, POST, PUT, DELETE, etc.). Note that in Laravel 11+, routes are typically defined directly in these files without a separate RouteServiceProvider.
    Route::get('/example', [ExampleController::class, 'index']);
  2. You have not included the required route parameters. If your route has parameters, make sure you are passing the required parameters in the URL or as part of the request:
    // Route definition
    Route::get('/users/{id}', [UserController::class, 'show']);
    // Request URL
    /users/1
  3. You have a typo in the route name or path. Make sure that you have spelled the route name or path correctly.
  4. Your routes are cached. Laravel caches routes for performance. If you recently added or modified routes, clear the cache:
    php artisan route:clear

If none of these solutions solve the problem, there could be other issues at play. It would be helpful to see the code for the route and the request that you are making in order to better understand the problem.