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

sujan7a's avatar
Level 14

Livewire not working on VPS (using CloudPanel).

I am encountering an issue with a Livewire form on my VPS (using CloudPanel), where the form is not doing anything. The same code works fine on a cPanel-hosted site and my local environment, but when I try to submit the form on the VPS (using CloudPanel), it submit the form (it should not submit the form because it is a livewire form) and displays the following error message:

Error: The POST method is not supported for route billing/29663/cart/online. Supported methods: GET, HEAD.

I am using Livewire v2 with Laravel 10.

0 likes
6 replies
LaryAI's avatar
Level 58

The error message you're encountering suggests that the route handling your Livewire form submission is not configured to accept POST requests. This can happen due to several reasons, especially when moving from one hosting environment to another. Here are some steps to troubleshoot and resolve the issue:

  1. Check Route Definition: Ensure that the route in your web.php file is set up to handle POST requests. If you're using a resource controller, make sure the correct methods are defined.

    Route::post('billing/{id}/cart/online', [YourController::class, 'yourMethod'])->name('your.route.name');
    
  2. Verify Livewire Component: Ensure that your Livewire component is correctly set up to handle form submissions. The method in your Livewire component should be public and should match the form's action.

    class YourComponent extends \Livewire\Component
    {
        public function submitForm()
        {
            // Handle form submission
        }
    }
    
  3. Check Form Submission: Make sure your form is set up to use Livewire's wire:submit directive, which should call the method in your Livewire component.

    <form wire:submit.prevent="submitForm">
        <!-- form fields -->
        <button type="submit">Submit</button>
    </form>
    
  4. Server Configuration: Since you're using a VPS with CloudPanel, ensure that your server is correctly configured to handle POST requests. Check your web server configuration (Nginx or Apache) to ensure there are no restrictions on POST requests.

  5. Check for Middleware: Ensure that there are no middleware in your Laravel application that might be blocking POST requests. Check your app/Http/Middleware and app/Http/Kernel.php for any custom middleware that might affect request methods.

  6. Clear Cache: Sometimes, cached routes or configurations can cause issues. Clear your application cache to ensure everything is up to date.

    php artisan route:clear
    php artisan config:clear
    php artisan cache:clear
    php artisan view:clear
    
  7. Check for CORS Issues: If your Livewire component is making requests to a different domain, ensure that CORS is properly configured to allow POST requests.

  8. Inspect Network Requests: Use browser developer tools to inspect network requests and ensure that the form submission is being sent as a POST request and that there are no JavaScript errors.

By following these steps, you should be able to identify and resolve the issue with your Livewire form not submitting correctly on your VPS. If the problem persists, consider checking server logs for more detailed error messages.

sujan7a's avatar
Level 14

@LaryAI not a single livewire component working. not even data table paginate.

sujan7a's avatar
Level 14

CloudPanel uses the NGINX server. I needed to modify the vhost file to remove js from the list of file extensions. The original list (css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map) was updated to (css|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map).

4 likes
deatram's avatar

@sujan7a Big thanks to you! I joined this forum just to tell you how much your solution saved me.

2 likes
sujan7a's avatar
Level 14

@deatram also need update the Nginx configuration by modifying the try_files directive as follows:

Change:

try_files $uri $uri/ /index.php?$args;

To:

try_files $uri /index.php?$args;

This adjustment ensures that requests are properly routed through index.php when a direct file or directory match is not found.

Please or to participate in this conversation.