Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

net::ERR_CONNECTION_REFUSED using Laravel 9, ReactJs with vite js

Tags:

npm

laravel

vite

I'm trying to build an app using Laravel 9 and ReactJS with vite js. I tried following command to build.

npm run dev

But I'm getting following errors,

GET http://[::1]:5173/resources/css/app.css net::ERR_CONNECTION_REFUSED

GET http://[::1]:5173/@vite/client net::ERR_CONNECTION_REFUSED

GET http://[::1]:5173/resources/js/app.jsx net::ERR_CONNECTION_REFUSED

GET http://[::1]:5173/@react-refresh net::ERR_CONNECTION_REFUSED

like image 337
Sourav Das Avatar asked Sep 02 '25 17:09

Sourav Das


2 Answers

If you entered npm run build on production, your .env file looks good, and you still have such errors as the author – just delete the file public/hot.

like image 139
Paweł Moskal Avatar answered Sep 04 '25 08:09

Paweł Moskal


For those using Laravel Sail, open the vite.config.js file and configure it like so:

export default defineConfig({

  plugins: [
    react(),
    laravel({
        input: ['resources/css/app.css', 'resources/js/app.js'],
        refresh: true,
    }),
  ], 
  server: {
    hmr: {
        host: 'localhost',
    },
  }
});

If need be, stop and restart the server sail npm run dev

like image 37
BlackPearl Avatar answered Sep 04 '25 09:09

BlackPearl