Laravel: Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined
Code called route('name') for a route name that doesn’t exist — very often route('login') from the auth middleware in API-only apps.
Route [login] not definedRoute [x] not defined Meaning
The auth middleware redirects guests to the route named login. API routes without a login route should return 401 JSON instead (send Accept: application/json, or customise redirectTo). Cached routes (route:cache) can also be stale.
Common causes
- No route named login when auth middleware redirects guests
- Typo in route name or route not named
- Stale route cache after deploy
- API request without Accept: application/json
⚡ Quick fix
- Name the route (->name('login')) or add one
- For APIs send Accept: application/json / customise the guest redirect
- php artisan route:clear (and route:cache again)
Detailed fix by platform
PHP
- php
// bootstrap/app.php (Laravel 11) ->withMiddleware(function (Middleware $m) { $m->redirectGuestsTo(fn ($request) => $request->expectsJson() ? null : route('login')); })
Shell
- php
php artisan route:list --name=login php artisan route:clear
How to diagnose
- Routes — route:list
- Request — Accept header (API)?
- Cache — Route cache stale?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Laravel
- The Mix manifest does not exist Laravel Mix: Illuminate\Foundation\Exceptions\... The Mix manifest does not exist. (public/mix-manifest.json)
- 403 This action is unauthorized Laravel: Illuminate\Auth\Access\AuthorizationException: This action is unauthorized.
- PDOException: could not find driver Laravel: Illuminate\Database\QueryException: could not find driver (SQL: select * from information_schema.tables)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026