YouTube Live

Stream Key Not Recognized or Invalid? How to Fix It on YouTube and Facebook

By the StreamLivestic team · · 16 min read

Stream Key Rejected — stream key not recognized

A "stream key not recognized" error means the platform took your connection, looked up the key your encoder sent, and found nothing it was willing to publish to. The key was reset, belongs to a different channel, has already expired, or something else is holding it. YouTube and Facebook word the rejection differently, and OBS, Streamlabs, vMix and FFmpeg each print their own version of it, which is why one problem sends people down four different rabbit holes.

You can tell those situations apart in about two minutes. Here is the order we work through on our own streams.

Quick fix: Copy the key again from the exact broadcast you are going live on, on the exact channel or Page that owns it. YouTube: Studio → Create → Go live → Stream tab → Copy next to the hidden key. Facebook: Live Producer → Go live → streaming software, and tick Use a persistent stream key so it survives the broadcast. Paste it with no trailing space, confirm the protocol matches (Facebook is RTMPS only), stop the encoder fully, then start again. If it still fails, reset the key and make sure nothing else is still pushing to the old one.

What the error actually means

RTMP publishing happens in two stages, and almost everyone blames the wrong one.

First your encoder opens a TCP connection to the ingest host and sends an RTMP connect with the application name, the part of the URL after the hostname: live2 for YouTube, rtmp for Facebook. If that fails you get a network error, and the key has not been looked at yet.

Then it sends publish with the stream name, which is your stream key. The server decides whether that key exists, is active, belongs to a live-enabled account and is free. If any of those is false it refuses the publish and closes the connection. That is the moment you get a stream key not recognized, invalid stream key or unauthorized message.

So the error does not mean "your key is a wrong string of characters". It means "I cannot publish to this key right now", and that includes keys that are spelled perfectly. Each tool reports the same refusal in its own words:

ToolWhat you seeWhat it really means
OBS Studio"Could not access the specified channel or stream key. If correct, there may be a server connection problem." (internally OBS_OUTPUT_INVALID_STREAM)The publish was refused, or OBS never reached the host. It cannot tell you which, which is why this message misleads so many people.
OBS Studio"Failed to connect to server", or 0 kb/s then a reconnect loopStage one. Port, host, VPN or firewall. Not the key.
Streamlabs DesktopThe same OBS wording, or a generic "Error while streaming" bannerSame two causes, plus a destination that is enabled when you did not mean it to be.
vMix"Server error: Publish Rejected: Invalid URL", often followed by "Operation not permitted"Stage two. The server read the key and said no.
FFmpegA "Server error:" line on the rtmp output, or "Operation not permitted", and the process exits in a few secondsPublish refused. FFmpeg is the most honest of the four: it prints the server's own message.
FFmpeg"Cannot open connection tcp://..." or a timeoutStage one. Host, port or TLS.

Any message that mentions the channel or stream key in the same breath as a server connection problem is a two-in-one error. Prove which half you have before you start changing keys.

The two kinds of stream key, and why that decides everything

Most of the confusion around a stream key not recognized error comes from treating all keys as permanent. Both platforms issue persistent keys and throwaway keys, and the two look identical.

On YouTube, the Live Streaming API makes the distinction explicit. A stream can be reusable, which the docs describe as one that "can be bound to multiple broadcasts", or non-reusable, in which case "it can only be bound to one broadcast" and, in YouTube's own words, "a non-reusable stream might be deleted by an automated process after the broadcast ends". That last sentence is the whole story behind "but it worked yesterday". In Studio that maps to three things:

Facebook works the same way with different labels. A one-off "Go live" session in Live Producer hands you a key tied to that single Live Video object. Meta's Live Video API documentation shows why: creating a live video returns a secure_stream_url, "the ingest URL that you will use to stream live video data from your encoder to the LiveVideo object". One object, one URL. When the object stops being live, the URL is done. For one that survives, tick Use a persistent stream key before you copy it.

We have seen both sides of this. On a Facebook Page test, the key we used stopped working the moment that 8-hour live ended: it had expired and we needed a new one for the next broadcast. A key from a one-off Go live session is not reusable the next day. On YouTube, the same persistent key kept working across repeated reconnects from our server through a continuous multi-hour test, without a single re-copy.

Meta's best-practices page is where that 8-hour ceiling comes from: you "can stay live for up to 8 hours". So on Facebook a single-use key has a hard expiry built in whether you plan for it or not.

Key typeWhere you get itSurvives the broadcast?What usually kills it
YouTube default keyStudio → Create → Go live → Stream tabYes, until someone resets itA Reset you did not make; copied from the wrong channel
YouTube custom keySelect stream key → Create new stream keyYes, across many broadcastsKey deleted; event pointed at a different custom key
YouTube key made with a scheduled eventThe event's own stream settingsOften not. Non-reusable streams may be removed after the broadcastReusing it for the next event
Facebook single-use keyLive Producer → Go live → streaming softwareNo. It belongs to that one Live VideoUsing yesterday's key today; the 8-hour limit ending the live
Facebook persistent keyLive Producer, with Use a persistent stream key tickedYes, across broadcastsMixing it up with a single-use key in the same encoder profile

Why the stream key not recognized error happens

These are the real causes, in the order we actually hit them, and a few of them never show up in the articles currently ranking for this.

  1. The key came from the wrong channel. If you manage Brand Accounts, Studio remembers whichever channel you were last on. The key is valid; it just belongs to another ingest. This is the single most common cause.
  2. The key was reset. Resets are instant and silent, and YouTube's help confirms owners and managers can do them. The moment one happens, every encoder, restreamer and hardware box still holding the old key starts failing.
  3. A Facebook single-use key has been consumed. The broadcast ended, by you or by the 8-hour limit, and the key went with it.
  4. A non-reusable YouTube key has been cleaned up. The scheduled event you created it with is finished, so the key is gone.
  5. Whitespace or truncation in the paste. A trailing space, a newline from a chat message, a key cut short because the Studio field was still masked, or a password manager autofilling the masked field behind your back.
  6. The key is in the wrong field, or joined to the URL wrongly. OBS and vMix want server and key separately; FFmpeg wants them joined with a single slash. An extra slash, a missing one, or a stray ?backup=1 in the middle gives the same rejection as a dead key.
  7. Protocol mismatch. Meta's Live Video API documentation states your app "must produce a live RTMPS stream", so plain RTMP to Facebook fails. YouTube takes both, but an RTMPS URL in an encoder that lacks RTMPS support gives a timeout that looks like a key problem, which YouTube's own RTMPS page warns about.
  8. Two encoders on one key. A second PC, a forgotten FFmpeg process, a cloud restreamer. The connections displace each other, so you get intermittent rejections instead of a clean failure, which makes this the hardest cause to spot.
  9. The account is not allowed to publish. YouTube can disable live streaming over Community Guidelines, copyright, age or "made for kids" reasons, and first-time enablement can take up to 24 hours. Meta states that since 10 June 2024 an account must be 60 days old, with 100 followers on a Page or professional-mode profile.
  10. An expired OAuth token, not a key at all. If you use OBS's or Streamlabs' "Connect Account" login, the failure is a broken authorisation and resetting keys will not touch it.
  11. The key leaked. If a key ever appeared in a tutorial, screenshot, shared config or Git repo, treat an unexplained rejection as a leak until proven otherwise.

How to fix it

1. Copy the key again from the exact broadcast, on the exact channel

Do this first even if you are certain. It costs 30 seconds and rules out causes 1, 2, 4 and 5 at once.

YouTube:

  1. Open Studio and check the channel name in the top-right avatar menu. Switch channel if you manage more than one.
  2. Create → Go live. For an instant stream stay on the Stream tab; for a scheduled one, open Manage and click into that event.
  3. Note the name shown in Select stream key. If it is not the key your encoder profile uses, you have found your problem.
  4. Click Copy next to the masked key. Never retype it off the screen.

Facebook: open Live Producer, start a new Go live with the streaming-software option, check that the selector shows the right Page or profile, tick Use a persistent stream key before copying, and copy the server URL and key separately.

Then paste it in:

Stop the encoder completely, wait five seconds, start again. Restarting matters: several encoders hold the old RTMP session open and keep failing against the stale key.

2. Rule out whitespace and a bad paste before you blame the platform

This is the cause people skip, and it produces a textbook stream key not recognized error. Check the string, not your memory of it. On Linux or macOS:

read -rs KEY            # paste, then press Enter
printf '%s' "$KEY" | wc -c
printf '%s' "$KEY" | cat -A | tail -c 40

cat -A marks the end of line with $, so a trailing space or carriage return shows up at once. If the character count changes when you re-copy, your clipboard was carrying something extra. Then build the URL the way your tool expects:

# YouTube, RTMPS, primary ingest
rtmps://a.rtmps.youtube.com/live2/YOUR-STREAM-KEY

# YouTube, plain RTMP, primary ingest
rtmp://a.rtmp.youtube.com/live2/YOUR-STREAM-KEY

# Facebook, RTMPS only
rtmps://rtmp-api.facebook.com:443/rtmp/YOUR-FACEBOOK-STREAM-KEY

One slash between the application name and the key, no trailing slash, no quotes inside the OBS or vMix field, and quotes around the whole URL in a shell command so nothing gets split.

3. Reset the key properly, then update every sender

Reset when the key may have leaked, when you cannot account for an extra sender, or when nothing else explains the rejection. YouTube's help gives the path: Studio → Create → Go Live → Stream tab → Reset next to the hidden key, then copy the new one into your encoder. Only owners and managers can do this.

The part people get wrong is the clean-up. A reset breaks everything still holding the old key, which is the point, but it means hunting them all down:

If you reset the key before every show just to get the stream to connect, something structural is wrong. That pattern fills OBS forum threads, and it is nearly always a second sender or an event bound to a different key, not a platform bug.

4. On Facebook, switch to a persistent key

If your Facebook stream works the first time and fails the next day, you are not fighting an error. You are using a key that was only ever valid for one broadcast. In Live Producer, start a new live from streaming software and tick Use a persistent stream key before you copy anything. That is the key you can schedule around and reconnect to.

Two caveats. The 8-hour ceiling still applies: a persistent key lets you start a fresh broadcast straight away, it does not make one run forever. And if the option is missing, create the live from Live Producer on desktop rather than a post composer or the mobile app.

5. Match the protocol, and know which error is which

Facebook requires RTMPS. YouTube accepts both, and in Studio you reveal the RTMPS URL with the lock icon in the Stream URL field.

One detail worth knowing: YouTube's backup ingest is a different address with the same stream key. The API exposes one streamName alongside both ingestionAddress and backupIngestionAddress. So if only the backup feed is rejected, the key is not the suspect.

6. Make sure only one encoder holds the key

One key, one sender. YouTube gives you a separate backup URL for redundancy; it does not expect two machines publishing to one primary key, and when they do the symptoms are intermittent rather than clean.

If you cannot find the extra sender, reset the key. Whatever held the old one loses access, and only the encoder you update will connect.

7. Re-authorise the account if you log in instead of pasting a key

OBS and Streamlabs can connect with an account login, which issues a token rather than a key you can see. When that token expires or its access is revoked, the failure reads like a stream key problem and no amount of resetting helps.

  1. OBS: Settings → Stream → Disconnect, then Connect Account again and re-approve. Afterwards use Manage Broadcast to pick the exact event, so OBS binds the right stream for you.
  2. Streamlabs: log out of the destination, reconnect it, then confirm it is enabled in the Go Live window.
  3. If you want certainty, drop account login and use a custom key instead. Fewer moving parts, and the failure modes are the visible ones in this article.

8. Confirm the account is actually allowed to publish

Sometimes the key is fine and the account is the blocker.

9. Test the key on its own with FFmpeg

This is the cleanest diagnostic there is, because it removes your scenes, camera, capture card and encoder settings from the picture. Send a synthetic signal that is known to be valid and see what the server says.

ffmpeg -loglevel level+info -re \
  -f lavfi -i testsrc2=size=1280x720:rate=30 \
  -f lavfi -i sine=frequency=1000:sample_rate=44100 \
  -c:v libx264 -preset veryfast -profile:v high -pix_fmt yuv420p \
  -b:v 3000k -maxrate 3000k -bufsize 6000k -g 60 -keyint_min 60 \
  -c:a aac -b:a 128k -ar 44100 -ac 2 \
  -f flv "rtmps://a.rtmps.youtube.com/live2/YOUR-STREAM-KEY"

Read it like this:

For Facebook, change only the last line to -f flv "rtmps://rtmp-api.facebook.com:443/rtmp/YOUR-FACEBOOK-STREAM-KEY" and read the result the same way.

Never paste a real key into a forum post, screenshot or shared log. Use a placeholder, the way these commands do. A key in a public log is a key someone else can stream on.

10. Symptom to cause, at a glance

SymptomMost likely causeFix
Worked yesterday, refused today (Facebook)Single-use key consumed when the broadcast endedPersistent stream key (fix 4)
Worked last month, refused now (YouTube scheduled event)Non-reusable key cleaned up after the eventCustom reusable or default key (fixes 1, 3)
Refused instantly with a server messageKey reset, wrong channel, or publishing blockedRe-copy, check account status (fixes 1, 8)
Connects, drops, retries every few secondsTwo encoders on one keyFind the extra sender or reset (fix 6)
Never connects with any keyPort 1935 blocked, VPN, no RTMPS supportRTMPS on 443 (fix 5)
Works in FFmpeg, fails in OBSWhitespace in the field, or a stale account tokenRe-paste unmasked, or re-authorise (fixes 2, 7)
On 24/7 loops the key question matters more than it does for a daily show, because nobody is sitting there to re-copy a key at 3am. That is the part StreamLivestic handles: one persistent key, one encoder in the cloud, reconnecting on its own. Whatever you run, the rule holds: one key, one sender.

How to stop it coming back

Nearly every stream key not recognized error we have chased down came from a habit, not a bug. Build these instead.

For the official detail, see YouTube on managing live stream settings and resetting a key, live streaming error messages and RTMPS, the liveStreams API reference for reusable versus non-reusable streams, and Meta's Live Video API documentation.

FAQ

Why does my stream key say invalid when I copied it correctly?

Because the error is about whether the platform can publish to that key right now, not whether you typed it correctly. A key that was reset, belongs to another channel, expired with a one-off Facebook broadcast, or is already in use by a second encoder will be refused even though the characters are perfect.

Does a YouTube stream key expire?

The default key on the Stream tab and custom keys you create do not expire; they last until someone resets or deletes them. Keys created with a scheduled event can disappear, because YouTube's API says a non-reusable stream might be deleted by an automated process after the broadcast ends.

Why does my Facebook stream key stop working after one broadcast?

A key from a one-off Go live session in Live Producer belongs to that single live video, so it dies with the broadcast. On our own Page test the key stopped working as soon as the 8-hour live ended and we needed a new one the next day. Tick "Use a persistent stream key" to get one you can reuse.

Can two encoders use the same stream key at once?

No. One key should have one sender. YouTube provides a separate backup ingest address that uses the same stream key for redundancy, but two machines publishing to the same primary key will keep displacing each other and produce intermittent rejections.

What happens when I reset a YouTube stream key?

The old key stops working immediately and everything still using it fails, including backup PCs, hardware encoders, restreamers and scripts. Only channel owners and managers can reset a key, and you need to paste the new one into every sender afterwards.

How do I tell a stream key error from a network error?

Run the FFmpeg test pattern command against the key. If the server refuses it within a couple of seconds with its own error message, it is a key problem. If it hangs or times out, it is the port, host or TLS, and port 1935 being blocked is the usual culprit.

Why does OBS say it could not access the specified channel or stream key?

That single OBS message covers two different failures: the server refused your publish, or OBS never reached the server at all. Test the same key with FFmpeg, or switch to RTMPS on port 443, to find out which half you have.

Stream keyYouTube LiveFacebook LiveOBS StudioStreamlabsvMixFFmpegRTMPSPersistent stream keyStreaming errors

Sources & official docs