Laravel + Vite = ERR_ADDRESS_INVALID Im trying to run my laravel application in a container with sail. Im using Vue with Vite.
Ive setup sail with no problem but when I try to run Vite I get:
GET http://0.0.0.0:5173/resources/js/app.js net::ERR_ADDRESS_INVALID
I've set the host for vite to 0.0.0.0 according to documentation I found here: https://laravel-vite.dev/guide/essentials/development.html#changing-the-host .
But I cant get it to work.
I have also set the ports in the docker-compose.yml:
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
vite.config.js:
export default defineConfig({
server: {
host: '0.0.0.0'
},
A solution that worked for me ventually is that I shouldve changed my vite.config.js to:
export default defineConfig({
server: {
host: '0.0.0.0',
hmr: {
host: 'localhost'
}
},
And afterwards execute npm install and npm run dev inside the laravel docker container.
@kevieman thanks a lot , you saved me from unspeakable consequences :'D
If you're running in a similar issue with a production build where the error is something along the lines of:
Failed to load resource: ....::ERR_CONNECTION_REFUSED
You can solve this by deleting the hot file in the public directory.
Source: https://stackoverflow.com/a/74714367/19044033
Please sign in or create an account to participate in this conversation.