Route [login] not defined Laravel Origin: Application & API OSI layer 7 · Application Last updated 13 Oct 2026

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.

Exact message you may see Route [login] not definedRoute [x] not defined
Seen on: Laravel

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

  1. Name the route (->name('login')) or add one
  2. For APIs send Accept: application/json / customise the guest redirect
  3. php artisan route:clear (and route:cache again)

Detailed fix by platform

PHP

  1. php
    // bootstrap/app.php (Laravel 11)
    ->withMiddleware(function (Middleware $m) {
        $m->redirectGuestsTo(fn ($request) => $request->expectsJson() ? null : route('login'));
    })

Shell

  1. php
    php artisan route:list --name=login
    php artisan route:clear

How to diagnose

  1. Routes — route:list
  2. Request — Accept header (API)?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1019 — Cloudflare Error 1019: Compute server error (Workers) (Cloudflare)1019401 — HTTP 401 Unauthorized (HTTP)401401 — 401 Unauthorized without WWW-Authenticate header (HTTP)401404 — HTTP 404 Not Found (HTTP)404404 — 404 only with or without a trailing slash (HTTP)404404 on all routes except home (public folder / .htaccess) — Laravel on shared hosting: homepage works but every other route returns 404 Not Found (Laravel)404 on all routes exc…405 — HTTP 405 Method Not Allowed (HTTP)405419 Page Expired — Laravel: 419 Page Expired (CSRF token mismatch) (PHP)419 Page ExpiredRoute [lo…

Explore the map of this error Full error map →

🧠 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.