Need help with node-turn?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

204 Stars 45 Forks MIT License 21 Commits 2 Opened issues


Node-turn is a STUN/TURN server for Node.JS

Services available


Need anything else?

Contributors list


npm version Build Status Coverage Status Dependencies Status

Node-turn is a STUN/TURN server for Node.JS

Supported RFCs:


Install from NPM.

$ npm install node-turn

Use Node-turn as a standalone server

$ cd ./node_modules/node-turn
$ su
# mkdir /etc/node-turn
# cp ./sample-config.conf /etc/node-turn/node-turn.conf
# chmod 640 /etc/node-turn/node-turn.conf
# touch /var/log/node-turn.log
# chmod 640 /var/log/node-turn.log
# exit
$ vi /etc/node-turn/node-turn.conf
$ npm run start

Use Node-turn as a library

var Turn = require('node-turn');
var server = new Turn({
  // set options
  authMech: 'long-term',
  credentials: {
    username: "password"

available options


Type Description
listeningPort Integer TURN listener port for UDP (Default: 3478).
listeningIps Array Listener IP address of relay server. Multiple listeners can be specified.If no IP(s) specified in the config, then all system IPs will be used for listening.
relayIps Array Relay address (the local IP address that will be used to relay the packets to the peer). Multiple relay addresses may be used.The same IP(s) can be used as both listening IP(s) and relay IP(s). If no relay IP(s) specified, then the turnserver will apply the default policy: it will decide itself which relay addresses to be used, and it will always be using the client socket IP address as the relay IP address of the TURN session (if the requested relay address family is the same as the family of the client socket).
externalIps Object External IP addres for relay address allocations. This is necessary if running the relay server behind a NAT. By default, the local relay IP is used, if externalIps is a string, then all allocations will use that address for the relayed address, if it's an object, then it takes the form of {"local ip 1": "external ip 1", "local ip 2": "external ip 2", default: "default external IP"} to specify an external IP per local relay IP. A special 'default' key can be set for use with any relay addresses that aren't listed in the object.
minPort Integer Lower bound of the UDP relay endpoints (Default: 49152).
maxPort Integer Upper bound of the UDP relay endpoints (Default: 65535).
authMech String TURN credential mechanism. cf authentification mechanism table lower. By default no credentials mechanism is used (any user allowed).
credentials Object User accounts for credentials mechanisms. username are object keys containing the password string.
realm String The realm to be used for the users with long-term credentials mechanism. (Default: '').
debugLevel String Server log verbose level. cf debug level table lower (Default: 'ERROR').
maxAllocateLifetime Integer the max lifetime, in seconds, allowed for allocations (Default: 3600).
defaultAllocatetLifetime Integer the default allocation lifetime in seconds (Default: 600).
debug Function Synchronous function used to log debug information that take debugLevel as first argument and string message as second.

Authentification mechanism

Auth mechanism

'none' disable authentification
'short-term' to use short-term mechanism (cf
'long-term' to use long-term mechanism (cf

debug level

Debug level

'OFF' nothing is logged
'FATAL' fatal errors are logged
'ERROR' errors are logged
'WARN' warnings are logged
'INFO' infos are logged
'DEBUG' debug infos are logged
'TRACE' traces are logged
'ALL' everything is logged

Library methods


arguments Description
start none start the server.
stop none stop the server.
addUser username (String), password (String) add a user to credential mechanism.
removeUser username (String) remove a user from credential mechanism.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.