Facebook Live
Facebook Live 8 Hour Limit: Why Your Stream Ended and Won't Reconnect
The Facebook Live 8 hour limit is a hard cap: once a single live video has been on air for 8 hours, Facebook ends it, and the stream key that video used stops accepting connections. Your encoder isn't broken and your internet didn't drop. It's knocking on a door that Facebook has closed, and it will keep knocking until you stop it and give it a new key.
What the error actually means
Each Facebook live video is a separate object with its own ingest session. Meta's developer docs spell out the rules: a stream URL has to be used within 24 hours of being created, and once used, it can be streamed to for up to 8 hours. The broadcast spec page says the same thing more bluntly: duration should "not exceed 8 hours". The Live Video API even has a field called seconds_left, described as the seconds left "in the maximum possible duration for this live video". Facebook is literally counting down.
When that counter reaches zero, Facebook ends the live, turns it into a normal video post on your Page, and closes the ingest for that key. From your encoder's side, here's what you see:
- OBS Studio / Streamlabs: the stream drops with "Disconnected", OBS tries to reconnect, and then you get "Failed to connect to server". The dialog usually suggests checking your stream service or firewall, which sends a lot of people hunting for a network problem that isn't there.
- FFmpeg:
Error opening output files: Input/output error, with exit code 251. That's simply FFmpeg's I/O error (EIO, -5) wrapped into an 8-bit exit code. The TLS connection tolive-api-s.facebook.com:443opens, the RTMP handshake is refused, and FFmpeg gives up within a couple of seconds. - vMix and other FFmpeg-based tools: a generic "FFMPEG exited" or "connection failed" message, followed by endless retries.
The giveaway is the timing. If the stream ran perfectly and died at about the 8-hour mark, and every reconnect after that fails immediately (not after a long timeout), the key is dead. Network faults look different: they hang, time out slowly, or recover on their own.
What we saw in our own test
We looped a 21-minute 720p rally video (H.264, 2-second keyframes, about 1.9 Mbps) to a Facebook Page from our cloud server, using FFmpeg over RTMPS. It ran for exactly 8 h 0 m, from 3:43 PM to 11:44 PM, with zero drops. Then Facebook ended the live.
The encoder didn't know that. It kept trying to reconnect with the old key once a minute, all night: 766 failed attempts, each one dying after about 2 seconds with Error opening output files: Input/output error (exit code 251). Nothing was wrong with the server, the file or the connection. The key was no longer valid, and no number of retries was going to change that.
That's the trap with "auto-reconnect forever" logic on Facebook. Normally it protects you from a network blip. After the 8-hour cut-off it just wastes the night and hides the real problem.
Why it happens: the Facebook Live 8 hour limit and other causes
The 8-hour cap is the most common reason a long Facebook stream ends on its own, but it isn't the only one. Here's every cause we know of, most common first.
- You hit the Facebook Live 8 hour limit. This applies to streams from encoders like OBS, vMix and FFmpeg. Mobile app broadcasts have historically had a shorter cap (4 hours when Facebook last raised it), so don't plan a long phone stream.
- The stream key was single-use and it's already been spent. A normal key belongs to one live video. When that video ends (because of the 8-hour cap, or because you or a moderator clicked End live video), the key is finished. Pasting the same key again tomorrow won't work.
- You were offline for longer than the reconnect window. Meta's support page says that if your feed drops, you have 2–3 minutes to reconnect to the original stream URL. Beyond that, Facebook ends the broadcast and you need a new key. Long router reboots, power cuts or a crashed PC all land here.
- The key expired before you used it. A stream URL created through the API has to be used within 24 hours. Scheduled lives can be set up to seven days ahead, but if you miss the start time by more than a few minutes, Facebook may not show your stream at all.
- The live sat in preview too long. When you start the encoder but never press Go live, Facebook holds the stream in preview. That preview window is limited to a few hours. Meta's developer docs don't state the exact number; streaming tool guides put it at 4–5 hours. If preview times out, the key is gone, even though you never went public.
- You're using plain RTMP or the wrong port. Facebook requires RTMPS (encrypted RTMP). The current ingest address is
rtmps://live-api-s.facebook.com:443/rtmp/. An oldrtmp://URL on port 80 or 1935 fails at the start, and so does a network that blocks outbound 443 to Facebook. - Your encoder settings are outside spec. Keyframes more than 4 seconds apart, bitrate well above the limit, or an unsupported codec can cause dropped or unstable streams. These usually fail early, not at hour 8, but they're worth ruling out.
- Your account or Page isn't eligible. Since June 2024, Meta requires the Facebook account to be at least 60 days old and the Page or professional-mode profile to have at least 100 followers before it can go live. New Pages hit this on their very first attempt.
- A copyright or policy action. Facebook can cut off a live that matches rights-managed audio or video. Check your Page notifications and Professional Dashboard if a stream dies at a random point with a warning.
How to fix it
1. Stop the encoder before you touch anything else
Don't let it keep retrying a dead key. In OBS or Streamlabs, click Stop Streaming. In vMix, turn off the Stream button. With FFmpeg, kill the process or stop your loop or service (for example systemctl stop yourstream). If you run a script that restarts FFmpeg on failure, stop the script too. That restart loop is exactly how we ended up with 766 attempts.
2. Create a new live video and get a fresh key
- Go to Facebook Live Producer (
facebook.com/live/producer) and pick the Page or profile you want to stream to. - Choose Streaming software as the video source.
- Under the stream setup section, either copy the new single-use key, or switch on Use a persistent stream key (see fix 4).
- Check that the server URL shown is
rtmps://live-api-s.facebook.com:443/rtmp/. - Add your title and description now. You can't edit everything after you go live.
3. Paste the new key into your encoder and go live
OBS Studio: Settings → Stream → Service: Facebook Live (or Custom with the RTMPS URL above) → paste the key → OK → Start Streaming. Then go back to Live Producer, wait until the preview shows your video, and click Go live.
Streamlabs Desktop: Settings → Stream → choose Facebook, or use Custom Ingest with the RTMPS URL → paste the key → Done → Go Live. If you've linked your Facebook account, Streamlabs can create the live for you, but check it picked the right Page.
vMix: click the cog next to Stream → Destination: Facebook (or Custom RTMP Server) → URL rtmps://live-api-s.facebook.com:443/rtmp/ → paste the key in Stream Name or Key → Start.
FFmpeg: the key goes at the end of the URL. To restream a file that's already encoded to Facebook's spec (like our test file), copy the streams without re-encoding:
ffmpeg -re -stream_loop -1 -i video.mp4 \
-c copy -f flv \
"rtmps://live-api-s.facebook.com:443/rtmp/YOUR_NEW_KEY"
If you're not sure the file has 2-second keyframes, re-encode it on the way out. This example is for 720p30:
ffmpeg -re -stream_loop -1 -i video.mp4 \
-c:v libx264 -preset veryfast -profile:v high -level 4.1 \
-pix_fmt yuv420p -r 30 -g 60 -keyint_min 60 -sc_threshold 0 \
-b:v 3000k -maxrate 3000k -bufsize 6000k \
-c:a aac -b:a 128k -ar 48000 -ac 2 \
-f flv "rtmps://live-api-s.facebook.com:443/rtmp/YOUR_NEW_KEY"
-g 60 at 30 fps gives you a keyframe every 2 seconds, and -sc_threshold 0 stops x264 from adding extra keyframes on scene cuts. If your FFmpeg says it doesn't know the rtmps protocol, your build was compiled without TLS (OpenSSL or GnuTLS). Install a full build rather than trying to tunnel around it.
Phone (Facebook app): just start a new live from the Page. There's no key involved, but the shorter mobile duration cap applies.
4. Use a persistent stream key so you don't have to re-paste
A persistent stream key stays the same across broadcasts. You set it once in OBS, vMix or FFmpeg and never touch it again. Turn it on in Live Producer under the stream setup options (Use a persistent stream key). If it ever leaks, Meta's support page says you can reset it from facebook.com/live/create by choosing the persistent key option and clicking Reset.
Be clear about what it does and doesn't do:
- It does save you from copying a new key into your encoder every time.
- It does not make one live video last longer than 8 hours. Each broadcast still ends at the cap.
- Each new broadcast still has to be created, and you still have to go live from Live Producer (or the API). Think of it as "same key, new live video, press Go live each time".
- Treat it like a password. Anyone who has it can stream to your Page.
5. Run longer than 8 hours the legitimate way: planned restarts
There's no setting that lifts the Facebook Live 8 hour limit on a normal broadcast, and anything sold as a "bypass" will get you into trouble. What works is chaining broadcasts:
- Plan your restart point at around 7 h 50 m, not 8 h 00 m. You get to choose the moment instead of Facebook choosing it for you mid-sentence.
- Stop the encoder cleanly and end the live in Live Producer.
- Create the next live (same persistent key, or a new key), start the encoder, wait for the preview, and click Go live.
- Put "Part 2", "Part 3" and so on in the titles so viewers can follow along. Pin a comment on the old video linking to the new one.
Viewers will see a short gap and a new video in their feed. That's normal for Facebook. A 24-hour stream is three broadcasts, not one.
6. Automate the restart with the Live Video API
If you run streams overnight or around the clock, don't rely on someone being awake at hour 8. The Live Video API lets you script the whole cycle:
- Create a live video on the Page with
POST /{page-id}/live_videosandstatus=LIVE_NOW(orUNPUBLISHEDto preview first). The response contains asecure_stream_url(RTMPS). - Start FFmpeg with that URL.
- Poll the live video's
seconds_leftfield. When it gets low, start the next live, switch FFmpeg to the new URL, and end the old one withPOST /{live-video-id}andend_live_video=true.
You need a Page access token with the right permissions and an app that's been through Meta's review for live video publishing. The API reference also lists a stream_type of AMBIENT, described as being for "continuous broadcasts that last days or weeks". It's thinly documented and we haven't tested it, so don't build a business on it without checking that it's available for your Page first.
7. Make your encoder give up when Facebook says no
Auto-reconnect is good. Infinite auto-reconnect against a closed key isn't. In OBS, go to Settings → Advanced → Automatically Reconnect and set a sensible retry delay and maximum retries, so it stops and you notice. With FFmpeg, wrap it in a script that counts fast failures and stops:
#!/usr/bin/env bash
URL="rtmps://live-api-s.facebook.com:443/rtmp/YOUR_KEY"
fails=0
while true; do
start=$(date +%s)
ffmpeg -re -stream_loop -1 -i video.mp4 -c copy -f flv "$URL"
code=$?
ran=$(( $(date +%s) - start ))
if [ "$ran" -lt 30 ]; then fails=$((fails+1)); else fails=0; fi
if [ "$fails" -ge 5 ]; then
echo "Facebook refused 5 times in a row (exit $code). Key is probably dead."
echo "Create a new live in Live Producer and update the key."
exit 1
fi
sleep 10
done
A run that lasted only a few seconds counts as a refusal. A run that lasted hours and then failed resets the counter, so a genuine network blip still gets retried. After that 8-hour night, we changed StreamLivestic to do exactly this: it detects Facebook's 8-hour cut-off and repeated refusals, stops cleanly, and tells you to create a new live and paste the new key.
8. Check your settings against Facebook's spec
If your stream dies early rather than at hour 8, or Facebook keeps showing a "poor connection" warning, compare your output to Meta's published requirements:
| Resolution | Frame rate | Video bitrate (Kbps) | H.264 level |
|---|---|---|---|
| 1080p (1920×1080) | 60 fps | 4,500 – 9,000 | 4.2 |
| 1080p (1920×1080) | 30 fps | 3,000 – 6,000 | 4.1 |
| 720p (1280×720) | 60 fps | 2,250 – 6,000 | 4.1 |
| 720p (1280×720) | 30 fps | 1,500 – 4,000 | 4.1 |
| 480p | 30 fps | 600 – 2,000 | 4.1 |
| 360p | — | 400 – 1,000 | 4.1 |
The rest of the spec:
- Max resolution: 1080p. Aim for 16:9. Meta warns that streams too far from that ratio may not be supported.
- Keyframe interval: 2 seconds recommended, and never more than 4 seconds. In OBS, set Keyframe Interval to 2 (Settings → Output → Output Mode: Advanced). Don't leave it on 0 ("auto").
- Video codec: H.264.
- Audio: AAC-LC, 44.1 or 48 kHz, stereo, 128 kbps preferred, 256 kbps maximum.
- Protocol: RTMPS only.
- Duration: at least 10 minutes is recommended, 8 hours maximum.
Our test stream sat at about 1.9 Mbps at 720p. That's in range for 720p30 and it ran without a single drop for the full 8 hours, so you don't need to push bitrate to the top of the range to get a stable stream.
How to stop it coming back
- Treat the Facebook Live 8 hour limit as a scheduling fact. Plan restarts at around 7 h 50 m, never "whenever it dies".
- Turn on a persistent stream key so a restart is "create live, press Go live", not "copy a new key into three places".
- Don't let your encoder retry forever. Cap OBS's retries, or use a script that stops after a few fast refusals.
- Always use
rtmps://live-api-s.facebook.com:443/rtmp/. Delete any oldrtmp://profiles saved in your encoder. - Set keyframes to 2 seconds and keep bitrate inside the range for your resolution and frame rate.
- Don't leave a stream in preview for hours. Go live soon after the preview looks right.
- Keep power and internet outages under 2–3 minutes (use a UPS on the router and PC), or the broadcast ends and the key goes with it.
- For 24/7 or overnight streams, automate the chain with the Live Video API, or use a tool that handles the cut-off for you.
- Check Page eligibility (60-day-old account, 100+ followers) before an important first broadcast.
For the official details, see Meta's Live Video API overview, the video and audio requirements, the Live Video API support notes (reconnect window and persistent key reset) and the LiveVideo Graph API reference.
FAQ
Why did my Facebook live stop at exactly 8 hours?
Facebook caps a single live video at 8 hours. When it reaches that limit, Facebook ends the broadcast, saves it as a video on your Page and closes the stream key it used.
Can I stream longer than 8 hours on Facebook Live?
Not in one normal broadcast. To run longer, end the live and start a new one, ideally just before the 8-hour mark. A persistent stream key or the Live Video API makes that restart quick, or fully automatic.
Why does OBS say 'Failed to connect to server' after my Facebook stream ended?
Your old stream key is no longer valid because the live video it belonged to has ended. Create a new live in Live Producer, or reuse your persistent key and start a new broadcast, then press Go live.
What does FFmpeg exit code 251 with 'Input/output error' mean on Facebook?
It's FFmpeg's I/O error code: Facebook's ingest server refused the connection. If it happens straight away on every retry after a long stream, the key is dead and you need a new live video.
Does a persistent stream key make my Facebook live last forever?
No. It keeps the same key across broadcasts so you don't have to re-paste it, but each live video still ends at 8 hours, and you still create and go live with each new broadcast.
What keyframe interval does Facebook Live need?
Meta recommends a keyframe every 2 seconds and says not to exceed 4 seconds. In OBS, set Keyframe Interval to 2 instead of 0 (auto).
How long can I be disconnected before Facebook ends my live?
Meta's support notes say you have about 2 to 3 minutes to reconnect to the same stream URL. After that, the broadcast ends and you need a new key.
Sources & official docs
- Meta for Developers: Live Video API overview
- Meta for Developers: Live Video API reference (audio and video specs)
- Meta for Developers: Live Video API best practices
- Meta for Developers: Support for Live Video API
- Meta for Developers: LiveVideo Graph API reference
- Meta for Developers: Schedule a broadcast
- Stage TEN: Streaming to Facebook via RTMP (preview window)


