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

SimonAngatia's avatar

How should you configure vite.config.js server option for production to avoid connection timedout error?

Could someone help me out? I can figure out how to configure vite.config.js server option for production. I am using this

server: {
        strictPort: 8001,
        https: true,
        hmr: {
            // host: "localhost",
            host: "bo.domain.com",
            port: 8001,
            protocol: "ws",
        },
    },

but when I open the application, I am encountering an error saying connection timed out and when I inpect the URL I find out that it is loading through port 5173. I am using the same setup on the domain name and it is working flawlessly. Anyone who could tell me the reason why this server setup is not working on the subdomain? I dont want the assets to be loaded through that port. What Am I supposed to do?

0 likes
6 replies
Sinnbeck's avatar

You dont set it up for production. You compile your assets with npm run build

As the command npm run dev implies, it is for dev (development) only

SimonAngatia's avatar

@Sinnbeck So in production I am supposed to comment out the server option on vite.config.js ? Because when it is on, I am always getting an error saying the connection is timedout and when I inspect, it is loading through the port 5173

Sinnbeck's avatar

@SimonAngatia No you just dont run npm run dev. And make sure there is no file named hot in the public directory. Delete it if there is

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@SimonAngatia then it sounds like you have a file named hot in the public directory. Delete it

SimonAngatia's avatar

@Sinnbeck True. I deleted that file and it finally worked. I have been figuring out this for a very long time. Thank you so much.

Please or to participate in this conversation.