Skip to content


Subversion checkout URL

You can clone with
Download ZIP
LiveReload 2.x-3.x web socket / http server
JavaScript CoffeeScript
Branch: master

Version bump to 0.2.3

Had to republish because I forgot to rebuild .js files in the last published version.
latest commit 39f5a98ccd
@andreyvit andreyvit authored
Failed to load latest commit information.
example Add an example
lib [server] Fix API compatibility with Node 0.10
test Handle EADDRINUSE
.gitignore Add an example
.npmignore Add an example
LICENSE Relicense under MIT Add an example
package.json Version bump to 0.2.3

LiveReload server in Node.js

Implementation of the server side of the LiveReload protocol in Node.js; a component of and some other projects.

Status: beta (expected to work, but not tested in production yet).


npm install livereload-server


See example/dummy-server.js for a runnable version of this code:

var fs   = require('fs');
var Path = require('path');
var LRWebSocketServer = require('livereload-server');

// id, name, version identifies your app;
// protocols specifies the versions of subprotocols you support
var server = new LRWebSocketServer({ id: "com.example.acme", name: "Acme", version: "1.0", protocols: { monitoring: 7, saving: 1 } });

server.on('connected', function(connection) {
  console.log("Client connected (%s)",;

server.on('disconnected', function(connection) {
  console.log("Client disconnected (%s)",;

server.on('command', function(connection, message) {
  console.log("Received command %s: %j", message.command, message);

server.on('error', function(err, connection) {
  console.log("Error (%s): %s",, err.message);

server.on('livereload.js', function(request, response) {
  console.log("Serving livereload.js.");
  fs.readFile(Path.join(__dirname, 'res/livereload.js'), 'utf8', function(err, data) {
    if (err) throw err;

    response.writeHead(200, {'Content-Length': data.length, 'Content-Type': 'text/javascript'});

server.on('httprequest', function(url, request, response) {

server.listen(function(err) {
    if (err) {
        console.error("Listening failed: %s", err.message);
    console.log("Listening on port %d.", server.port);


© 2012, Andrey Tarantsov, distributed under the MIT license.

Something went wrong with that request. Please try again.