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

nutmix's avatar

nginx returns 405 (Method Not Allowed) for PUT or DELETE

We are using forge to deploy an standard laravel app.

We use PUT as well as POST, but all puts are rejected by nginx before they even reach laravel:

405 Not Allowed

405 Not Allowed

nginx/1.13.3

The nginx config was created by forge.

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Our app works flawlessly under apache, but PUTs dont work under nginx/forge

We have exhausted all google responses to this problem, including things like this:

error_page 405 = $uri; 

Which didnt help.

Our PUTs look like this:

http://www.ourdomain.com/games/reskin/1003/1/savetext Request Method:PUT

Laravel routes are defined like this: Route::put('/games/reskin/{idgame}/{tabnr}/savetext','reskinController@savetexts');

Although its not even hitting laravel.

If we change the PUTs to POSTS, it then hits laravel, but then larvel returns MethodNotAllowedHttpException from ajax calls for no reason, but again only on nginx, works fine under apache. As there is no solution to this,we want to try using PUT (which some have said solves this exception issue).

0 likes
3 replies
ejdelmonico's avatar

Can you execute a curl PUT request to the server? Have you tried adding dav_methods PUT to the config? Also, verify that you have write permissions for the PUT.

Also, you do have {{ method_field('PUT') }} in your form right?

nutmix's avatar

The PUT is a laravel (php) api call, so there should be no write permissions required. We have not put dav_methods into the nginx conf as putting dav handling on a production server would decrease security. however, we will try it.

Please or to participate in this conversation.