'Vite Server is running but not working on localhost

Vite + Reactjs server is running but I am getting "This localhost page can’t be found No webpage was found for the web address: https://localhost:4200/" on the browser



Solution 1:[1]

Make sure your index.html file is in the root directory for your Vite project

Solution 2:[2]

I have the same problem and it's related to the project folder name. It had some spaces in the name of the project folder. I removed spaces and the node_module folder then I installed packages again, and now it's working fine.

Solution 3:[3]

TLDR: Change the Port

For me, it was that I already had something running on the port that Vite was trying to serve the app on (3000).

Doing a quick lsof -nPi :3000 (MacOSX) I saw that my docker desktop was running on that port.


You can do this statically by updating a server key in the vite config (vite.config.js)

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    port: 8000
  }
})

Or dynamically via the start command: vite --port 8000


https://vitejs.dev/config/#config-file

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henry Ecker
Solution 2 Mehdi Nasiri
Solution 3