I have node.js, npm, and live-server installed on my server:
# node -v
v20.5.1
# npm -v
9.8.0
# live-server -v
live-server 1.2.2
I want to connect to the live-server server remotely. In my firewall, I opened port 8080 for both incoming and outgoing. When I run live-server, I’m able to connect to the server remotely.
However, my local browser doesn’t get live updates when I update files. I don’t see any errors in Chrome or from live-sever, I just don’t get the updates.
How can I get those live updates?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Live-server is built to provide instant updates to your local browser every time a file is updated in your server. If you’re not receiving those updates, it could be because the WebSocket connection that live-server uses is blocked or not functioning properly. You might need to ensure that your firewall allows WebSocket connections.
Besides, if your live-server instance is running inside a Docker container or behind a reverse proxy, you may need to make sure these configurations also allow WebSocket traffic.
Make sure to check your browser console for any potential errors related to WebSocket connections.
Hope that this helps!
Heya,
When you run
live-server
on your remote server and connect to it with a local browser, the browser establishes a WebSocket connection back to the server for live-reloading. This WebSocket connection allows the server to send messages to the browser to trigger a page reload whenever files change.The issue you’re encountering may be related to WebSockets not working correctly due to the following reasons:
WebSocket Port: The WebSocket may be trying to use a different port than 8080, and this port might not be open on your firewall.
WebSocket Origin Restrictions: There might be CORS (Cross-Origin Resource Sharing) or origin restrictions preventing the WebSocket connection from being established.
Here’s how you can diagnose and potentially fix these issues:
Check the WebSocket Connection:
Allowing All Origins in live-server:
To avoid potential WebSocket origin issues, try running
live-server
with the following command:This disables CORS checks, which might solve the problem if it’s origin-related.
Check Other WebSocket Ports:
If WebSockets are not using port 8080, you need to figure out which port they are using and open it on your firewall.
Use a Reverse Proxy:
If you are familiar with tools like Nginx or Apache, you could set up a reverse proxy to handle the connection to the live-server. This way, you can ensure WebSockets work correctly, and you have more control over which ports are exposed and how traffic is routed.
Check Console for Errors:
Inspect the browser console for any error messages. Sometimes these errors can provide hints or direct explanations of what’s going wrong.
Consider Using a Different Tool:
If
live-server
continues to be problematic, you might consider other tools like BrowserSync, which can also handle live-reloading and might offer better configurability or clearer error messages.Lastly, ensure you don’t have any browser extensions (like ad blockers or security extensions) that might be interfering with the WebSocket connections.
Hi there,
This sounds like an issue with your host binding. By default, many local development servers bind to
localhost
or127.0.0.1
. This means they only accept connections from the same machine they are running on. You need to ensurelive-server
binds to0.0.0.0
. This means it will accept connections from any IP address.You can do this using:
After that, along with your firewall rule, it will be able to accept connections as normal.
Let me know how it goes!
Best,
Bobby