Back to Error Center
405 Method Not Allowed
Error Message
405 METHOD_NOT_ALLOWED
Cause
The HTTP method used (GET, POST, etc.) doesn't match the route definition. The route exists but for a different HTTP verb.
Solution
Check the route definition for the correct HTTP method. Use the right form method in HTML (@method for PUT/DELETE). Verify the AJAX request method.
Code Example
Fix
// Route only accepts POST
Route::post('/posts', [PostController::class, 'store']);
// HTML forms need @method for PUT/DELETE
<form action="/posts/{{ $post->id }}" method="POST">
@csrf
@method('PUT')
<button type="submit">Update</button>
</form>
// Check the correct route exists
Route::put('/posts/{post}', [PostController::class, 'update']);
Debugging Steps
- Run php artisan route:list to check HTTP methods
- Verify the form method attribute
- Check AJAX request method
- Ensure @method directive is present for PUT/DELETE/PATCH
Prevention
Use Route::resource() for consistent CRUD routes. Always include @method in HTML forms. Match form actions to route definitions.