Skip to main content
LIVE_HUD STREAMRELAY LAB // MEDIAMTX RTMP -> LL-HLS / WHEP / SRT AUDIT 2026-11-19 | GO RSS: 90-450 MB | EGRESS: UNMETERED VDS VS 10 GBPS
MediaMTXRTMP
MediaMTXRTMP Disclosure: Outbound /go/ links marked rel="sponsored" may earn a referral fee at zero checkout surcharge (Disclosures).
Broadcast Errors // StreamRelay Lab

MediaMTX maxReaders & Linux Ephemeral Socket Exhaustion

Default systemd LimitNOFILE (1024) and conservative maxReaders caps reject new viewers around 400-800 concurrent connections even when bandwidth is available.

Measured MediaMTX & FFmpeg Telemetry

Each HLS or WebRTC viewer consumes file descriptors for TCP/TLS sockets, epoll handles, and segment reads. Hitting RLIMIT_NOFILE causes MediaMTX and Caddy/Nginx to drop new viewer handshakes with 502/503 errors.

Subsystem / SignalMeasured TargetOperational Impact
Default Linux Soft NOFILE1,024 descriptorsFails around 400-500 active viewers
Production LimitNOFILE1,048,576 descriptorsSupports 3,000-20,000+ viewers cleanly
MediaMTX maxReaders0 (unlimited) or 1.35x peakPrevents accidental self-throttling

Step-by-Step Triage & Config Remediation

  1. Raise LimitNOFILE in systemd: Set LimitNOFILE=1048576 in both mediamtx.service and your TLS reverse proxy unit.
  2. Increase somaxconn & ephemeral ports: Tune net.core.somaxconn=65535 and net.ipv4.ip_local_port_range=1024 65535.
  3. Size maxReaders to 1.35x target: Set maxReaders in mediamtx.yml above peak viewer projections (e.g., 4,050 for 3,000 viewers).
# Verify open file limit of running MediaMTX PID:
cat /proc/$(pgrep mediamtx)/limits | grep "Max open files"

Diagnostic FAQ

Should MediaMTX terminate TLS directly or behind Caddy/Nginx?

For 500-3,000 viewers, Caddy or Nginx on localhost with HTTP/2 + KeepAlive handles Let’s Encrypt certificates and CORS headers cleanly.

Does maxReaders: 0 have a downside?

Setting 0 disables reader limits, which is fine if you monitor NIC saturation; setting 1.35x expected peak protects against runaway hotlinking.

Related Broadcast Errors Guides

MediaMTXRTMP: Size egress Mbps & ABR cores before go-live Launch UltaHost VDS