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

InspiredPrynce's avatar

Laravel 405 method not allowed in live hosting

I have a project thats working well on localhost but when i uploaded to the server the post ajax calls stopped working... It says 405,

$.ajax({
            url: url,
            method: 'post',
            cache: false,
            contentType: false,
            processData: false,
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            data: data,
            success(response) {
                console.log(response)
                
            },
            error(response) {
               
            }
        })

Route::post('/chart/save/points', 'DataController@save')->name('office.charts.generate.save'); This is my routes file...

What could be the cause?

0 likes
17 replies
jlrdw's avatar

As a step 1 check your letter case, Linux is case sensitive.

If live server is HTTPS, make sure all your calls are https.

InspiredPrynce's avatar

case sensitive, how? looking at the code i posted, please direct me which case doesnt match thanks

automica's avatar

@inspiredprynce look in your network tab on your browser. Does the url of the request match what you see in your routes?

you may find that your routes have been cached so the route you are trying to hit may not be available

Run php artisan route:clear to clear your routes cache.

Another thing which maybe an issue is that your route has a forward slash at the start.

/chart/save/points

should be:

chart/save/points

InspiredPrynce's avatar
POST
	
scheme
	https
host
	office.asklox.com
filename
	/office/dashboard/charts/chart/save/points

This is what i get when i checked the request headers

I have also cleared my route multiple times already

Snapey's avatar

Is your site hosted in the root of the domain or do you see a subfolder or (shudders) /public ?

InspiredPrynce's avatar

subdomain it also happened in the domain root so i kept it in the subdomain

Snapey's avatar

sub domain (myothersite.example.com) or subfolder (example.com/myothersite) Any routes you have in ajax requests need to take into account what is the 'root' for the site

jlrdw's avatar

Did you change your environment file to reflect production. Like changing localhost.

Of course run config:clear after any changes.

jlrdw's avatar

You could try:

Route::post('/chart/save/points', 'DataController@save')->name('office.charts.generate.save'); 

change to

Route::post('/chart/save/points', 'DataController@save'); 

And for your ajax url:

url: 'your_base_url/chart/save/points',

You would need a route:clear

jlrdw's avatar

You are clearing browser cache each code change, right.

Snapey's avatar

check your routes with php artisan route:list then compare it with the network request you are actually making by looking at the network inspector in the browser dev tools.

Gakesh's avatar

Laravel return 405 when uploading file if you exceed your php.ini max_upload_file_size

iftekhs's avatar

Open your console go to the Network tab and make the request and check in which route exactly the request is getting sent. Then match that route with your defined route.

Please or to participate in this conversation.