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

faridfr's avatar

can't open project routes after 'npm run dev' in laravel vite with laradock

I have installed Laravel with Laradock, and Breeze with Vue ( which has Inertia in it ). Now I run the project with docker-compose exec workspace bash and npm run dev The only page that I see in every route is :

laravel vite inertia

Changes in routes web.php and resources/js/app.js and resources/js/pages were detected in hot reload but do not work. I also tried --host and change host and hmr in vite.config but it was not helpful. every route in localhost:5173 shows one page. It should be said that 5173 is open in docker-compose.yml.

0 likes
30 replies
Sinnbeck's avatar

It seems that you are opening the dev url for vite, not laravel. Be aware that you now have 2 urls. One for vite (which you should just ignore) and one for laravel (the one you would work on normally)

faridfr's avatar

Thanks for your reply, but I'm not in production and want to develop. If I open Laravel URL, I see slow pages with no hot reload and do not see the latest changes in vue.js files.

Sinnbeck's avatar

@faridfr Yeah you would never use npm run dev in production. What I am saying is that while developing there are 2 servers. 1 is for laravel and one is for vite. You use the laravel one and laravel uses the vite one (in blade)

VIte does not write to any files when in dev mode. It injects the js and css directly into the website.

How are you checking the hot reloading? Are you seeing any errors in the console?

faridfr's avatar

@Sinnbeck

  • docker containers is up
  • npm run dev run with this results :

laravel vite inertia

  • when I open localhost with port 5173 I saw images in question
  • when I open APP_URL I saw project routes but very slow and with blank screen with js load errors.
Sinnbeck's avatar

@faridfr Ah I can see in your url that you are in fact not running the site with https. Try setting https: false, and try again. What error is it giving now?

faridfr's avatar

@Sinnbeck due to my npm run dev results that I sent here, Vite running with http. But to be sure I set it manually in vite.config and the result are the same.

Sinnbeck's avatar

@faridfr So if you turn off https (false) it is still saying empty response in the error?

Sinnbeck's avatar

Try adding this inside the server: {}

        hmr: {
            host: '127.0.0.1',
        },

so it looks like this

    server: {       
        hmr: {
            host: '127.0.0.1',
        },
       host: '127.0.0.1'.
    },
faridfr's avatar

@Sinnbeck

I tried with: 127.0.0.1, localhost, and 0.0.0.0 but every time results are same ( empty response in errors with these URLs )

Here is my vite.config :


import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    server: {
        hmr: {
            host: '127.0.0.1',
        },
       host: '127.0.0.1',
    },
    plugins: [
        laravel({
            input: 'resources/js/app.js',
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
});

Sinnbeck's avatar

@laksh Are you running npm run dev inside of docker? Which container? Is the port open on that container?

faridfr's avatar

@Sinnbeck yes. I added 5173 on workspace ports and I wrote commands on the workspace.

Sinnbeck's avatar

@faridfr Ok I honestly dont know. If you can get that url to show your content it all should start working.

Maybe try just this

server: {       
        hmr: {
            host: '127.0.0.1',
        },
    },
johnkarlocachero's avatar

I am also experiencing this issue. The solution I use is run yarn run dev in local (outside laradock) then your-project.test will work normally

I hope someone can solve this. I'll be following this thread since this is exactly my problem

1 like
lsatolli's avatar

In laradock is not open the 5173 port. Modify the docker compose file of workspace and restart laradock and it will work. I’ve tested it today

rayasabari's avatar

I have the same issue and solved by adding this object in vite.config.js

 server: {
        hmr: {
            host: 'localhost'
        },
    }

If you are using Valet or another virtual host like WAMPP, your can fill the host value with 'yourapp.test' Note: If you are using windows, make sure to define the localhost to 127.0.0.1 in the hosts file in system32/drivers/etc

makowskid's avatar

Laradock with WSL2 on Win 11, solved this with :

  • making sure localhost is configured in hosts file as 127.0.0.1
  • making sure WORKSPACE_VITE_PORT=5173 is set in .env in laradock
  • do not set HTTPS in vite.config.js
  • adding this to vite.config.js:
    server: {
        host: '0.0.0.0',
        hmr: {
            host: 'localhost'
        },
    },```
8 likes

Please or to participate in this conversation.