Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite + Laravel + Inertia - ERR_CONNECTION_REFUSED on npm run dev

I started having an issue starting from today when running npm run dev when running php artisan serve --host=IP using vite + laravel (i'm using breeze boilerplate as a starter).

Basically, it was working just fine for over a month until today, i started having the error ERR_CONNECTION_REFUSED [::1]:5173.

I tried changing the server in vite.config.js as follows:

export default defineConfig({
    server: {
        host: "0.0.0.0",
        port: 5173,
        hmr: {
            host: "127.0.0.1",
        },
    },
...

The only ways i can make it work is either by running npm run build or by manually putting the server on the vite.config.js

export default defineConfig({
    server: {
        host: "192.168.31.166",
        port: 5173,
        hmr: {
            host: "192.168.31.166",
        },
    },
...

I do not want to have to change the server manually every time, as i don't have a fixed IP Address and use 2 different wifi configurations based on if I'm at work or working remotely. Did anyone face those issues? I tried running npm update and composer update so i'm on latest versions for Laravel (10.8.0) and Vite (4.3.1), it didn't fix it.

Thank you in advance!

TL;DR: Tried running npm run dev and php artisan serve --host=IP and got an ERR_CONNECTION_REFUSED instead of the normal behaviour (was working just fine before)

like image 819
doctibby Avatar asked Dec 10 '25 08:12

doctibby


1 Answers

Seems you have run npm run dev before and the public/hot file wasn't destroyed when you stopped running it. Removing the hot file should solve your issue.

answer from laracast

like image 175
Luis Adames Avatar answered Dec 12 '25 06:12

Luis Adames



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!