question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite keeps refreshing the page with logs stuck in `connecting`

See original GitHub issue

Describe the bug

Vite keeps refreshing the page and logs are stuck with connecting... server connection lost. polling for restart...

log

Reproduction

Here is the codesandbox of the official react template package. This one is stuck while I was trying (image above).

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
    Memory: 7.89 GB / 15.85 GB
  Binaries:
    Node: 16.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - C:\Users\Prince~1\AppData\Roaming\npm\yarn.CMD
    npm: 7.11.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 92.0.4515.107
    Edge: Spartan (44.19041.1023.0), Chromium (92.0.902.62)
    Internet Explorer: 11.0.19041.1

Used Package Manager

npm

Logs

[vite] connecting... 
[vite] server connection lost. polling for restart...

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lubomirblazekczcommented, Jan 8, 2022

Ok, I’ve managed to resolve it for myself. I’ve had to define host where vite is running, because by default it’s taken from window.location.hostname, so that’s why it never connects.

hmr: {
    host: 'localhost'
}
1reaction
nickbiencommented, Mar 2, 2022

@jsjoeio Yes, this config got it working for us.

thanks! clientPort did the trick for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vite
If you are running Vite with WSL2, Vite cannot watch file changes in some conditions. See server.watch option. A full reload happens instead...
Read more >
javascript - Vite - React - App keeps refreshing with log: Server ...
Issue : Suddenly app keeps refreshing indefinitely giving this log in console: server connection lost polling for restart.
Read more >
How to Fix the 504 Gateway Timeout Error on Your Site - Kinsta
One of the first things you can try when encountering a 504 Gateway Timeout error is to wait a few minutes and try...
Read more >
Troubleshooting - Gitpod
These logs contain information about the workspace, the session, and the Visual Studio Code environment. They are useful for diagnosing connection issues ...
Read more >
Errors – Vercel Docs
Via the CLI, Logs or dashboard, follow the link, if available, in the description of the error. If not, search for the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found