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

theUnforgiven's avatar

Vite - Multiple sites

Is there a way when using Valet, Sail and Vite to have multiple sites all running at the time?

I have tried to run sitea.test and siteb.test at the same time but as they share the same port on Vite that doesn't work. I wondered if anyone had overcome this and how?

0 likes
1 reply
LaryAI's avatar
Level 58

Yes, you can run multiple sites at the same time using Valet, Sail, and Vite. The key is to configure each site to use a different port on Vite.

Here's how you can do it:

  1. In your vite.config.js file for each site, you need to specify a different port. For example, for sitea.test, you might have:
export default {
  server: {
    port: 3000
  }
}

And for siteb.test, you might have:

export default {
  server: {
    port: 3001
  }
}
  1. Then, in your sail configuration, you need to map these ports to your application. You can do this in the docker-compose.yml file. For example:
services:
  sitea:
    ports:
      - '3000:3000'
  siteb:
    ports:
      - '3001:3001'
  1. Finally, in your Valet configuration, you need to set up a proxy for each site to the corresponding port. You can do this using the valet proxy command. For example:
valet proxy sitea http://localhost:3000
valet proxy siteb http://localhost:3001

Now, you should be able to access sitea.test and siteb.test at the same time, each running on its own Vite server.

1 like

Please or to participate in this conversation.