Setting Up a Coturn Server for Nextcloud Talk WebRTC Communication

Understanding WebRTC and the Need for TURN

WebRTC (Web Real-Time Communications) is a technology that enables peer-to-peer audio and video communication directly within web browsers without requiring additional plugins. This technology powers real-time communication features in various applications, including Nextcloud Talk.

When implementing WebRTC-based solutions like Nextcloud Talk, you may encounter connectivity issues in certain network environments. This is where TURN (Traversla Using Relays around NAT) servers become essantial. They facilitate communication in scenarios where direct peer-to-peer connections fail due to NAT traversal limitations.

Installing and Configuring Coturn

To establish a reliable WebRTC connection for your Nextcloud Talk instance, you'll need to set up a TURN server. Coturn is an open-source implementation of TURN and STUN servers that works well with Nextcloud.

Step 1: Install Coturn

Begin by connecting to your server via SSH. Ensure your server has a properly configured domain name. Then install the coturn package:

sudo apt update
sudo apt install coturn

Step 2: Verify Installation and Stop Service

After installation, stop the coturn service to prepare for configuration:

sudo systemctl stop coturn
sudo systemctl status coturn

Verify that the service is stopped (no "running" status should be displayed).

Step 3: Enable Coturn Service

Edit the default configuration file to enable the coturn service:

sudo nano /etc/default/coturn

Uncomment the line TURNSERVER_ENABLED=1 to enable the service.

Step 4: Configure Turn Server

Now, edit the main turnserver configuration file:

sudo nano /etc/turnserver.conf

Add or modify the following settings (adjust the port number if needed):

listening-port=3478
fingerprint
it-cred-mesh
use-auth-secret
static-auth-secret=north
server-name=yourdomain.com      # Replace with your domain
realm=yourdomain.com            # Your domain without protocol prefix
total-quota=100
stale-nonce=600
bps-capacity=0
no-loopback-peers
no-multicast-peers

Step 5: Generate Authentication Secret

Create a secure authentication secret using OpenSSL:

sudo sed -i "s/north/$(openssl rand -hex 32)/" /etc/turnserver.conf

Step 6: Start the Coturn Service

Restart the coturn service with your new configuration:

sudo systemctl start coturn

Step 7: Configure Firewall Rules

Open the necessary ports in your server's firewall. For the default configuration, you'll need to allow both TCP and UDP traffic on port 3478:

  • For Ubuntu/Debian: sudo ufw allow 3478/udp and sudo ufw allow 3478/tcp
  • For cloud servers, configure the security group to allow traffic on these ports

Step 8: Configure Nextcloud Talk

Finally, configure Nextcloud Talk to use your new TURN server:

  1. Navigate to Nextcloud Talk settings
  2. Select "TURN only" mode
  3. Enter your domain and port (e.g., yourdomain.com:3478)
  4. Enter the authentication secret you generated earlier

If configured correctly, you should see a green checkmark indicating successful authentication.

Troubleshooting Tips

  • Verify your TURN server is accessible from external networks using tools like curl or online TURN testing tools
  • Check the coturn logs with sudo journalctl -u coturn for any errors
  • Ensure your domain's DNS records properly point to your server

Tags: coturn WebRTC Nextcloud TURN server VoIP

Posted on Sat, 10 Oct 2026 16:53:22 +0000 by Hades