Simple, robust, BitTorrent tracker (server) implementation

Usage no npm install needed!

<script type="module">
  import btTrackerServer from '';


bt-tracker-server travis npm downloads javascript style guide

Simple, robust, BitTorrent tracker (server) implementation

tracker visualization

Node.js implementation of a BitTorrent tracker, client and server.

A BitTorrent tracker is a web service which responds to requests from BitTorrent clients. The requests include metrics from clients that help the tracker keep overall statistics about the torrent. The response includes a peer list that helps the client participate in the torrent swarm.


  • Includes server implementations
  • Supports all mainstream tracker types:
  • Supports ipv4 & ipv6
  • Supports tracker "scrape" extension
  • Robust and well-tested
  • Tracker statistics available via web interface at /stats or JSON data at /stats.json

Also see bittorrent-dht.

Tracker stats



npm install bt-tracker-server



To start a BitTorrent tracker server to track swarms of peers:

var Server = require('bt-tracker-server')

var server = new Server({
  udp: true, // enable udp server? [default=true]
  http: true, // enable http server? [default=true]
  ws: true, // enable websocket server? [default=true]
  stats: true, // enable web-based statistics? [default=true]
  filter: function (infoHash, params, cb) {
    // Blacklist/whitelist function for allowing/disallowing torrents. If this option is
    // omitted, all torrents are allowed. It is possible to interface with a database or
    // external system before deciding to allow/deny, because this function is async.

    // It is possible to block by peer id (whitelisting torrent clients) or by secret
    // key (private trackers). Full access to the original HTTP/UDP request parameters
    // are available in `params`.

    // This example only allows one torrent.

    var allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
    if (allowed) {
      // If the callback is passed `null`, the torrent will be allowed.
    } else {
      // If the callback is passed an `Error` object, the torrent will be disallowed
      // and the error's `message` property will be given as the reason.
      cb(new Error('disallowed torrent'))

// Internal http, udp, and websocket servers exposed as public properties.

server.on('error', function (err) {
  // fatal server error!

server.on('warning', function (err) {
  // client sent bad data. probably not a problem, just a buggy client.

server.on('listening', function () {
  // fired when all requested servers are listening
  console.log('listening on http port:' + server.http.address().port)
  console.log('listening on udp port:' + server.udp.address().port)

// start tracker server listening! Use 0 to listen on a random free port.
server.listen(port, hostname, onlistening)

// listen for individual tracker messages from peers:

server.on('start', function (addr) {
  console.log('got start message from ' + addr)

server.on('complete', function (addr) {})
server.on('update', function (addr) {})
server.on('stop', function (addr) {})

// get info hashes for all torrents in the tracker server

// get the number of seeders for a particular torrent

// get the number of leechers for a particular torrent

// get the peers who are in a particular torrent swarm

The http server will handle requests for the following paths: /announce, /scrape. Requests for other paths will not be handled.

command line

$ npm install -g bt-tracker-server

Easily start a tracker server:

$ bt-tracker-server
http server listening on 8000
udp server listening on 8000
ws server listening on 8000

Lots of options:

$ bt-tracker-server --help
  bt-tracker-server - Start a bittorrent tracker server

    bt-tracker-server [OPTIONS]

  If no --http, --udp, or --ws option is supplied, all tracker types will be started.

    -p, --port [number]  change the port [default: 8000]
        --trust-proxy    trust 'x-forwarded-for' header from reverse proxy
        --interval       client announce interval (ms) [default: 600000]
        --http           enable http server
        --udp            enable udp server
        --ws             enable websocket server
    -q, --quiet          only show error output
    -s, --silent         show no output
    -v, --version        print the current version


MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.