Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Tutorial Free

Laravel: "Route not defined": Easiest Way to Fix

July 21, 2023
2 min read

If you build links and call them by route names, you may get an error like "Route [register] not defined". But you could swear that the name is correct! I will show you the easiest way to debug and fix it.

This is the error I'm talking about:

In this case, you go to your routes file and clearly see that the route is called "register"!

routes/auth.php:

Route::get('register',
[RegisteredUserController::class, 'create'])
->name('register');

What you may be missing is that route may be in a group that adds a prefix to the name. The tricky part is that group may be defined in various places:

  • In the same Routes file
  • In a different Routes file that includes the current file
  • Or, even in RouteServiceProvider globally

So, how to debug?

Easy. Go to Terminal and type:

php artisan route:list

It will show you all the routes in your project, and if you find "register", you may find that the real full route name is auth.register:

If you have a big project and you're struggling to find your route in the list, you may filter it:

php artisan route:list --name=register

Now, you may try to find the file that contains the prefix('auth'):

Route::middleware('guest')
->prefix('auth')
->as('auth.')
->group(function () {
 
// ... many other routes in that group ...
 
Route::get('register',
[RegisteredUserController::class, 'create'])
->name('register');

But in this case, the real solution is to actually fix the name of your route wherever you call it: from route('register') to route('auth.register').

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.