Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
DocumentaryTube
FFmpeg

Nginx RTMP YouTube Stream Stops When SSH Disconnects: Fix on Ubuntu

Find the process publishing to YouTube, keep SSH-launched FFmpeg running with systemd, and troubleshoot NGINX RTMP or ingest failures separately.

By DocumentaryTube Team 5 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your YouTube stream stops when you close SSH, first find out which process publishes the stream. An FFmpeg command started at the SSH prompt usually needs to run under a persistent process manager such as systemd. If NGINX RTMP is already configured to push the stream and runs as a system service, an SSH disconnect alone should not stop NGINX; check its service status and logs instead.

Find the process that sends video to YouTube

NGINX RTMP may receive a feed and relay it, or FFmpeg may publish directly. Identify which process owns the outgoing connection to YouTube before changing configuration. Note the process and its command while connected, but do not expose the stream key when recording or sharing that information.

  • FFmpeg was started in your SSH shell: the publisher is tied to the login environment. Move it into a systemd service for a server-owned, persistent publisher.
  • NGINX RTMP pushes the stream: check the NGINX service state and logs. If NGINX is running as a system service, the SSH session ending does not by itself explain why the relay stopped.
  • The process remains active but YouTube ends the stream: investigate ingest health separately. A live process does not prove that it is sending valid, continuous video.

Run an SSH-launched FFmpeg publisher with systemd

For a long-running publisher on Ubuntu, create a system service that runs FFmpeg directly. The example below is schematic: replace the bracketed portion with the real input and encoding options, and replace the destination with the correct YouTube ingest URL. It is not a working command until those details are supplied.

[Unit]
Description=YouTube RTMP publisher
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=streamer
WorkingDirectory=/srv/stream
ExecStart=/usr/bin/ffmpeg [your input and encoding options] -f flv [your YouTube ingest URL]
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Set the service account, paths, and secret safely

Use the actual FFmpeg executable path, an account intended to run the publisher, and a working directory that exists. Use absolute paths for inputs and make sure the service account can read them. Keep the stream key in private configuration with access restricted to that account; do not place it in a world-readable unit file, source control, or public logs. A restricted environment file or a systemd credential mechanism may be appropriate depending on the Ubuntu and systemd versions installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Load and start the service

  1. Save the unit as /etc/systemd/system/youtube-publisher.service.
  2. Tell systemd to reload unit definitions: sudo systemctl daemon-reload.
  3. Enable it at boot and start it now: sudo systemctl enable --now youtube-publisher.service.
  4. Check its state: sudo systemctl status youtube-publisher.service.
  5. Read recent service output and errors: sudo journalctl -u youtube-publisher.service.

Ubuntu’s Jammy systemd service manual recommends Restart=on-failure for long-running services. It asks systemd to try recovery after a failure; an intentional systemctl stop does not trigger a restart. Systemd also enforces start-rate limits, so repeated failures call for diagnosis rather than an endless restart loop. See the Ubuntu systemd.service manual.

If NGINX RTMP itself pushes the stream

  1. Check whether NGINX is running: sudo systemctl status nginx.
  2. Inspect its service logs: sudo journalctl -u nginx.
  3. Validate the configuration before reloading: sudo nginx -t.
  4. If validation succeeds, reload NGINX using the service procedure for your installation; if it fails, correct the reported configuration error first.

The NGINX RTMP module is third-party in NGINX Open Source builds. Do not assume package directions for NGINX Plus apply to an Ubuntu Open Source installation. The cited NGINX package procedure is specifically for NGINX Plus; see NGINX’s RTMP module documentation and the upstream RTMP module.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Check the YouTube ingest if the service stays active

RTMP is a transport protocol, not a process manager. FFmpeg’s protocol documentation describes RTMP URL components and shows FLV as an output format; check the actual input, encoder options, destination, and stream key used by your publisher. The cited FFmpeg manual is for Ubuntu Noble, so verify behavior against the installed FFmpeg version: FFmpeg protocol documentation.

If using RTMPS, use the endpoint shown in YouTube Live Control Room and confirm that your encoder supports it. YouTube describes RTMPS as RTMP over TLS/SSL; switching from RTMP to RTMPS does not solve a process-lifetime problem. See YouTube’s live-streaming instructions.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Troubleshoot a stream that ends after logout

  1. Before disconnecting: record which process publishes to YouTube and how it was started. Redact the stream key.
  2. After reconnecting: check whether the process still exists. If it disappeared, determine whether it was launched from the shell, a service failed, or the process exited on its own.
  3. Inspect the service: run systemctl status <unit> and journalctl -u <unit>. Look for the exit status and recent error messages; distinguish a failure from an intentional stop.
  4. Check access and paths: confirm the service account can read the input and that input, executable, and working-directory paths are correct.
  5. Check the private ingest settings: verify the URL and stream key against YouTube Live Control Room. Do not paste the key into public logs or support posts.
  6. Check media and network health: inspect FFmpeg or NGINX output, YouTube Live Control Room health, outbound network access, and whether the input produces data continuously.
  7. If NGINX is involved: run nginx -t and inspect NGINX logs before changing relay directives.

Choose systemd or a detached terminal session

Approach Best fit Lifecycle and recovery Operator access
systemd service A server-owned publisher that should run independently of an SSH login. Can start at boot and apply a configured failure-restart policy; inspect status and logs through systemd. No need to attach to an interactive shell for routine operation.
tmux or another terminal multiplexer An operator-managed session where detaching and later reattaching is useful. Detaching a terminal session is not the same as configuring a service lifecycle or failure-restart policy. Useful when an operator wants to reconnect to the session.

This is an operational distinction, not a claim about a specific tmux release. For a persistent server publisher, systemd is the practical default because it provides service management and configurable restart behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or let it run in the cloud

If your goal is simply to keep uploaded video live on YouTube without maintaining an Ubuntu publisher, StreamNeo is a different route: upload your recording or build a playlist, add your YouTube stream key, and go live. Its cloud service loops uploaded videos, so nothing has to stay on at home; it does not go live from a camera. Any upload quality up to 4K 60fps streams as uploaded at one price per slot, and automatic recovery is included if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. Start the free day on StreamNeo.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Screening Room

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.