Registry / web-framework / livereload

livereload

JSON →
library2.7.1pypypi✓ verified 22d ago

Python LiveReload is a tool for web developers that automatically reloads webpages in the browser when file changes are detected. It provides a WSGI-compatible server and a command-line utility, focusing on simple, real-time feedback during development. The current version is 2.7.1, with a release cadence that includes bug fixes and minor enhancements.

pip install livereload
INSTALL
IMPORT
SIG · LIVERELOAD
L
livereload
web-frameworkpythonv2.7.1
Install
1.8s avg
Import
457ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.494s · 21.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.420s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server
from livereload import Server
shell
from livereload import shell

This quickstart creates a simple HTML file, then starts a LiveReload server that watches for changes to any `.html` files in the current directory. It will automatically open a browser tab to `http://localhost:5500` and reload it when files change.

import os from livereload import Server, shell # Create a dummy index.html for demonstration with open('index.html', 'w') as f: f.write('<!DOCTYPE html>\n<html><head><title>LiveReload Test</title></head><body><h1>Hello, LiveReload!</h1></body></html>') server = Server() server.watch('*.html') server.serve(open_url_delay=1)
livereload --version
Debug
Known issues
breakingThe `Guardfile` configuration method was removed in version 2.0.0. Older setups relying on a `Guardfile` will no longer work.
fix
Rewrite your watch rules using the Python API `server.watch()` within a Python script instead of a `Guardfile`.
affects: <2.0.0
gotchaWhen watching a large number of files, or during a build process that generates many files, `livereload` can trigger excessive reloads and high CPU usage.
fix
Use the `delay` parameter in `server.watch(filepath, func=None, delay=None)` to debounce reloads, or specify more granular file patterns to watch.
affects: All versions
gotcha`livereload` internally uses `Tornado`'s IOLoop. Improper integration with existing `Tornado` applications or other async loops can lead to issues, especially around the loop's lifecycle.
fix
Ensure that `livereload`'s server and your application's `IOLoop` (if any) are properly managed. Version 2.7.1 includes a fix for IOLoop stopping, but complex `Tornado` integrations may still require careful handling.
affects: All versions
gotchaWhile a command-line interface (`livereload` command) is available, it's recommended to use the Python API for more advanced or custom watching scenarios, especially since the removal of `Guardfile`.
fix
Create a Python script (e.g., `serve.py`) that imports `Server` and `shell` and defines your watch rules programmatically, then run it with `python serve.py`.
affects: >=2.0.0
gotchaWhen running behind a reverse proxy, particularly with HTTPS, the `livereload.js` client might attempt to connect via `ws://` instead of `wss://`, leading to connection errors.
fix
Configure your reverse proxy to correctly handle WebSocket connections and ensure that the `Host` and `X-Forwarded-Proto` headers are passed through, or specify `liveport` explicitly if needed.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'livereload'
The `livereload` package is not installed in the Python environment being used, or the Python interpreter cannot find it.
fix
Install the `livereload` package using pip: `pip install livereload`.
TypeError: WSGIContainer.environ() missing 1 required positional argument: 'request'
This error typically occurs when `python-livereload` is used with a newer version of `Tornado` (6.3.0 or higher), as the `WSGIContainer.environ()` method in `Tornado` changed its signature and is no longer a static method.
fix
Downgrade the `Tornado` library to a version prior to 6.3.0 by specifying it in your requirements or installation command: `pip install 'tornado<6.3.0'`.
LiveReload exception: <urlopen error [Errno 61] Connection refused>" or "Could not connect to LiveReload server"
The browser client cannot establish a connection with the LiveReload server, which can be due to the server not running, being blocked by a firewall, or the client trying to connect to the wrong host or port.
fix
Ensure the LiveReload server is running (e.g., `livereload` from the command line or via a Python script calling `server.serve()`). Check that no other application is using the default LiveReload port (35729 or 5500 for `server.serve()`) and that your firewall isn't blocking the connection. If using a custom host/port, ensure consistency between server and client configuration. For Django, ensure `django-livereload-server` is configured correctly.
Page not reloading / displaying cached files (browser caching issue)
While LiveReload successfully signals the browser to refresh, the browser often serves cached versions of CSS or JavaScript files instead of the updated ones, especially in browsers like Chrome.
fix
To force the browser to fetch fresh assets, append a dynamic version query parameter to your static file URLs (e.g., `?version={{ time() }}` in Flask templates) or disable browser caching during development in your browser's developer tools.
unknown command:'livereload' (when running python manage.py livereload)
This error occurs in a Django project when the `django-livereload-server` application is not correctly installed or configured in `settings.py`, preventing Django from recognizing the `livereload` management command.
fix
Ensure `django-livereload-server` is installed (`pip install django-livereload-server`) and `livereload` is added to your `INSTALLED_APPS` in `settings.py` before `django.contrib.staticfiles`.
Upgrade
Version history
2.7.1latest on PyPI · released Dec 18, 2024
Audit
Dependencies
pyinotifyoptionalRecommended for performance on Linux for file watching.
Agent activity
5 hits · last 30 days
node
4
Resources