On this page
- How does an Icecast station fit together?
- How do you install Icecast?
- Which settings in icecast.xml matter first?
- How do you stream a playlist from the server itself?
- How do live DJs connect from their own computer?
- How do you add HTTPS for listeners?
- What should the firewall allow?
- How can you see who is listening?
- Questions
How does an Icecast station fit together?
Icecast is the relay in the middle: it does not play files itself. A source client encodes audio (from a playlist or a microphone) and sends it to a mount point; Icecast fans that single stream out to every connected listener. Because the encoding happens in the source, the server only copies bytes, so a 1 vCPU plan handles hundreds of listeners.
The constraint is outgoing transfer. A 128 kbit/s MP3 stream uses about 58 MB per listener per hour, so 50 listeners for 8 hours a day come to roughly 700 GB a month. Compare that with the transfer listed for each plan on the prices page. Broadcast only music you are licensed to play publicly; radio licences are usually handled through the collecting societies of your listeners' countries.
How do you install Icecast?
Icecast 2.4 is in the main archive of Ubuntu and Debian. The package asks a few questions during installation; answer yes to configure it now and give it the hostname and passwords.
sudo apt update
apt policy icecast2
sudo apt install -y icecast2
icecast2 -v
systemctl status icecast2 --no-pager
sudo ss -tlnp | grep 8000If you skipped the questions, run sudo dpkg-reconfigure icecast2 later or edit the XML file directly as shown next. The service runs as the unprivileged icecast2 user and logs to /var/log/icecast2/.
Which settings in icecast.xml matter first?
Open /etc/icecast2/icecast.xml with sudo nano and adjust these blocks. Use long random passwords; generate one with openssl rand -base64 18.
<limits>
<clients>200</clients>
<sources>3</sources>
</limits>
<authentication>
<source-password>CHANGE-source-secret</source-password>
<relay-password>CHANGE-relay-secret</relay-password>
<admin-user>admin</admin-user>
<admin-password>CHANGE-admin-secret</admin-password>
</authentication>
<hostname>radio.example.net</hostname>
<listen-socket>
<port>8000</port>
</listen-socket>The clients limit protects your monthly transfer, and hostname is used in the playlist files Icecast generates. Apply the changes with sudo systemctl restart icecast2.
How do you stream a playlist from the server itself?
FFmpeg can loop a folder of tracks and push it to Icecast, which is enough for a simple automated station. Install it and build a playlist file:
sudo apt install -y ffmpeg
mkdir -p ~/radio
cd ~/radio
for f in /srv/radio/*.mp3; do echo "file '$f'"; done > playlist.txt
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \
-vn -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 \
icecast://source:CHANGE-source-secret@127.0.0.1:8000/radio.mp3The -re flag sends audio at real-time speed. For crossfades, jingles, schedules and automatic fallback when a live DJ disconnects, sudo apt install liquidsoap gives you a scriptable broadcaster that outputs to Icecast with output.icecast. To keep the FFmpeg feed running after you log out, wrap it in a systemd unit (see systemd services) or a tmux session.
How do live DJs connect from their own computer?
Desktop broadcasting apps and DJ software can send to Icecast directly. Enter these values in the app:
- Server type: Icecast 2
- Address:
radio.example.net, port 8000 - Mount:
/live.mp3(a separate mount keeps it apart from the automated feed) - User:
source, password: your source password - Format: MP3 128 kbit/s or Ogg Opus 96 kbit/s
To let a DJ take over the automated stream automatically, add a mount block for /live.mp3 with <fallback-mount>/radio.mp3</fallback-mount> and <fallback-override>1</fallback-override>, and point listeners at the live mount. For this to work, port 8000 must be reachable, as configured below.
How do you add HTTPS for listeners?
Browsers block plain HTTP audio on HTTPS websites, so serve the stream through Nginx with a certificate. Create a DNS record for radio.example.net, then:
sudo apt install -y nginx certbot python3-certbot-nginx
sudo tee /etc/nginx/sites-available/icecast >/dev/null <<'EOF'
server {
listen 80;
listen [::]:80;
server_name radio.example.net;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_read_timeout 1d;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/icecast /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d radio.example.netTurning off buffering and raising the read timeout keep long listening sessions alive. Certificate renewal is covered in the Certbot guide.
What should the firewall allow?
Listeners use 443, and port 8000 is only needed if DJs broadcast from outside.
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw allow 8000/tcp
sudo ufw enableIf all sources run on the server, drop the 8000 rule. To restrict DJs to known addresses, use sudo ufw allow from 203.0.113.50 to any port 8000 proto tcp instead. Source passwords travel in plain text on port 8000, so rotate them when a DJ leaves.
How can you see who is listening?
Icecast publishes live statistics. The admin pages at https://radio.example.net/admin/ ask for the admin user and password and show every mount, its listeners and the source address. For scripts, query the JSON endpoint:
curl -s http://127.0.0.1:8000/status-json.xsl | python3 -m json.tool
sudo tail -f /var/log/icecast2/access.logTrack how much transfer the station actually uses with the tools in usage monitoring.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Icecast internet radio
Which audio format should I broadcast?
MP3 at 128 kbit/s plays everywhere. Opus in Ogg sounds better at 64 to 96 kbit/s and saves transfer, but a few older players cannot handle it. Some stations offer both on two mounts.
Why does my player say the stream is not found?
No source is connected to that mount, or the mount name differs by a letter or extension. Check the admin page for active mounts and the error log in /var/log/icecast2/error.log.
Can I relay my stream to a second server?
Yes. Icecast supports relays: the second server pulls a mount from the first with the relay password, which spreads listeners and transfer across two plans.
How many listeners can one plan handle?
CPU is rarely the limit. Divide the monthly transfer of the plan by the data per listener hour (about 58 MB at 128 kbit/s) to see how many listener hours fit.
Is Icecast related to SHOUTcast?
They are separate servers that both speak a similar HTTP streaming style. Many players handle either; see the SHOUTcast guide for the other one.