Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Livewire's JavaScript file returns 404 and components do nothing

ErrorGET /livewire/livewire.js net::ERR_ABORTED 404 (Not Found)

Short answer

Livewire serves its JavaScript through a Laravel route, so a 404 means the request never reached that route. The usual reasons are a web server rule that blocks the path, a stale route cache, or disabled asset injection without the @livewireScripts directive. Publishing the assets removes the route dependency.

  • Applies to Livewire 3, Laravel 12, nginx 1.26, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the browser network tab and copy the exact URL of the failing script request, then see whether the page source contains a script tag for it at all.

    php artisan route:list | grep -i livewire
    curl -s https://example.com | grep -i "livewire"
  2. 2Match what you see, then jump to its fix

    1. 1route:list on the server lacks the Livewire script route, or the app was deployed with cached routes from before the package was installed.Stale route cacheFix
    2. 2The route exists in route:list, but the script URL still returns 404 through the web server.The web server blocks the script pathFix
    3. 3The page source has no Livewire script tag, so the browser never asks for one.Asset injection is off and the directive is missingFix

What does the error look like?

  • GET /livewire/livewire.js net::ERR_ABORTED 404 (Not Found)
  • Livewire components render but wire:click and wire:model do nothing

Cause 1 of 3

Stale route cache

1Check

The Livewire installation page lists cached routes as one cause of the 404.

php artisan route:list | grep -i livewire

2Fix

Clear the route cache, and rebuild it after the deploy if you use it.

php artisan route:clear
php artisan route:cache

3Verify

The route list now includes Livewire's route and the script loads.

php artisan route:list | grep -i livewire

Confirmed by livewire.laravel.com

Did this fix it?

Cause 2 of 3

The web server blocks the script path

1Check

The script path contains a hash derived per installation, so a location rule for static files can swallow it and return 404 before PHP runs. The Livewire page names nginx rules as a cause.

sudo nginx -T | grep -n "location"

2Fix

Make sure the path is handed to Laravel's front controller, or publish the assets so the file is served as a real static file.

php artisan livewire:publish --assets

3Verify

Request the script URL from the page source and expect a 200.

curl -s https://example.com | grep -i "livewire"

Confirmed by livewire.laravel.com

Did this fix it?

Cause 3 of 3

Asset injection is off and the directive is missing

1Check

Livewire injects its assets automatically into pages that contain components. If inject_assets is disabled, or the page has no component, you must add the directives yourself.

grep -rn "inject_assets" config/livewire.php
grep -rn "livewireScripts" resources/views/

2Fix

Put the styles directive in the head and the scripts directive before the closing body tag of the layout.

<head>
    @livewireStyles
</head>
<body>
    {{ $slot }}
    @livewireScripts
</body>

3Verify

Reload and confirm the script tag is in the page source.

curl -s https://example.com | grep -i "livewire"

Confirmed by livewire.laravel.com

Did this fix it?

How do I stop it coming back?

  • Run php artisan route:clear in the deploy script before route:cache so routes match the installed packages.
  • Check the Livewire script URL after changing nginx rules or adding a CDN in front of the site.
  • If you publish assets, keep them current by re-running the publish command after Livewire updates.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

PHP stops the script after 30 seconds

Symfony\Component\ErrorHandler\Error\FatalError: Maximum execution time of 60 seconds exceeded

PHP ends a script that runs past max_execution_time (30 seconds by default for web requests).

5 causes, each with a fix

Back end

Why a Filament panel feels slow on a Laravel server

The panel is fast on a small demo and slow once there are many resources, pages and widgets

A slow Filament panel on a server is most often running without the production caches.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.