Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tlovaj's avatar

MethodNotAllowedHttpException ln 251 and how to debug

Hello I am new to laravel and am currently going through the laravel from scractch series. I am currently stuck on this error and cannot figure out what is going on:

MethodNotAllowedHttpException ln 251 in RouteCollection.php line 251 at RouteCollection->methodNotAllowed(array('GET', 'HEAD')) in RouteCollection.php line 238

Project URL: http://localhost/blog/public HTML: Route: Route::POST('comments', 'CommentsController@store');

I am going from http://localhost/blog/public/posts to http://localhost/blog/public/posts/comments

route:list shows that it is indeed a POSt metho on URI comments.

Also, does anyone have valuable tips on how to debug such issues these errors seem to be so vague to me?

I am using PHPconsole and firebug and those don't seem to be much help at this point. I have also enabled debug logging am not getting much help from that.

Thanks!

EDIT:: So i've figured it out after some time. although my action="comments" whats actually getting passed to my routes is "post/comments".

Which leads me to another question: how can i determine what actually gets passed to my routes?

0 likes
1 reply
Snapey's avatar

very, very, very first thing is to setup local hosting properly so that /blog/public is not needed in your urls

the way it is set now, you will just constantly get strange errors

as for debugging, you can see a lot in your browser with the inspector and the network tab.

if in your routes you expect to get a POST request to blog/comments, if you look in the network tools you will see the request goes to /blog/public/posts/comments which will not find a match in your routes

1 like

Please or to participate in this conversation.