Set up a Local TURN Server for Nextcloud Talk

The latest Nextcloud (31 and up) recommends setting up and using HPB (High Performance Backend) for the Talk app, which makes sense because it is designed for that purpose to work efficiently with it. It requires resources, hardware, and someone to set it up for you. However, if you are a small team of up to 5 users, you don’t need HPB; a local TURN server on Nextcloud will suffice. So, read on to learn how to set up a local TURN server for the Nextcloud Talk app.

What this article was tested on:

  • Ubuntu 24.04 server
  • Nextcloud 31
  • Talk 21

If you haven’t installed Nextcloud yet, you can follow this guide to install it.

Let’s proceed with the installation.

Installation

First, log in to your Ubuntu server and run the update command to update the system.

apt update && apt upgrade

Next, install the Coturn package.

apt install coturn

Open the following file for editing.

nano /etc/default/turnserver

Uncomment or add the following to it:

TURNSERVER_ENABLED=1

If you have a firewall enabled, allow port 3478.

sudo ufw allow 3478/tcp
sudo ufw allow 3478/udp
sudo ufw reload

Configuration

Coturn has a default configuration file at the /etc/ location. However, we will not use it, as it may be cumbersome to enable or disable settings in it. Instead, we will copy it and create our own.

mv /etc/turnserver.conf /etc/turnserver.conf.bak
nano /etc/turnserver.conf

Copy the content below, adjust it to your needs, and paste it into the editor.

Note: If you are on a public cloud server, use your server’s IPv4 for listening-ip; if you are on a local network (Proxmox or anything else), use the server’s local IP. You can obtain the local IP via ip a. Don’t use 127.0.0.1.

Replace <SECRET> with your own strong secret. It will be used in Nextcloud later.

listening-port=3478
listening-ip=192.168.1.100
realm=localhost
server-name=localhost
static-auth-secret=<SECRET>
userdb=/var/lib/turn/turndb
no-cli
no-tls
no-dtls

Save the file and start the Coturn server.

systemctl start coturn
systemctl enable coturn

systemctl status coturn

Nextcloud Talk

Go to Nextcloud Administration and click on Talk.

Scroll down to Turn servers option and click on ‘Add a new TURN server‘ button.

Nextcloud-turn-server-setup

TURN server URL = 192.168.1.100:3478 (change to your IP)

TURN server secret = your secret from turnserver.conf

Click check (health) icon to confirm.

Nextcloud-turn-server-config

If something is not working on Talk side or not connecting, check logs with journalctl -u coturn -f. Check the IP in turnserver.conf, change it around and see if it works.