YouTube Live
Stream Key Not Recognized or Invalid? How to Fix It on YouTube and Facebook
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.
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:
| Tool | What you see | What 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 loop | Stage one. Port, host, VPN or firewall. Not the key. |
| Streamlabs Desktop | The same OBS wording, or a generic "Error while streaming" banner | Same 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. |
| FFmpeg | A "Server error:" line on the rtmp output, or "Operation not permitted", and the process exits in a few seconds | Publish refused. FFmpeg is the most honest of the four: it prints the server's own message. |
| FFmpeg | "Cannot open connection tcp://..." or a timeout | Stage 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:
- The default key on the Stream tab. The persistent one. It stays the same until an owner or manager clicks Reset.
- Custom keys created under Select stream key → Create new stream key. YouTube's help describes these as the way "to reuse the same stream key", and they can be assigned to any event.
- Keys created along with a scheduled event. These are the ones that quietly stop existing: the event is over, the stream object behind it is cleaned up, and the key in your encoder profile points at nothing.
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 type | Where you get it | Survives the broadcast? | What usually kills it |
|---|---|---|---|
| YouTube default key | Studio → Create → Go live → Stream tab | Yes, until someone resets it | A Reset you did not make; copied from the wrong channel |
| YouTube custom key | Select stream key → Create new stream key | Yes, across many broadcasts | Key deleted; event pointed at a different custom key |
| YouTube key made with a scheduled event | The event's own stream settings | Often not. Non-reusable streams may be removed after the broadcast | Reusing it for the next event |
| Facebook single-use key | Live Producer → Go live → streaming software | No. It belongs to that one Live Video | Using yesterday's key today; the 8-hour limit ending the live |
| Facebook persistent key | Live Producer, with Use a persistent stream key ticked | Yes, across broadcasts | Mixing 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.
- 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.
- 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.
- 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.
- A non-reusable YouTube key has been cleaned up. The scheduled event you created it with is finished, so the key is gone.
- 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.
- 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=1in the middle gives the same rejection as a dead key. - 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.
- 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.
- 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.
- 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.
- 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:
- Open Studio and check the channel name in the top-right avatar menu. Switch channel if you manage more than one.
- Create → Go live. For an instant stream stay on the Stream tab; for a scheduled one, open Manage and click into that event.
- Note the name shown in Select stream key. If it is not the key your encoder profile uses, you have found your problem.
- 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:
- OBS Studio: Settings → Stream → Service: YouTube - RTMPS or Facebook Live → Server: Primary → Stream Key. Click the eye icon to unmask and check the end of the string.
- Streamlabs Desktop: Settings → Stream. Either pick the broadcast on a logged-in destination, or switch that destination to a custom stream key. Check no second destination is still enabled.
- vMix: Settings → Outputs / NDI → Streaming → pick the destination, then paste into Stream Name or Key, with the server in its own field.
- FFmpeg: join the two with one slash in the output URL, as shown below.
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:
- Every OBS or Streamlabs profile on every machine, including the backup laptop.
- Hardware encoders that auto-start on boot, plus cloud restreamers and scheduling tools.
- Scripts, systemd units and
.envfiles:grep -ril "live2/" /etc /opt /home 2>/dev/null
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.
- Refused immediately with a server message: key problem.
- Times out or never connects: protocol, port or encoder capability. Plain RTMP uses TCP 1935, which plenty of office, campus and hotel networks block. RTMPS runs on 443 and usually walks through.
- SSL or handshake errors on an rtmps URL: add the port,
rtmps://a.rtmps.youtube.com:443/live2, and check the encoder supports RTMPS at all.
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.
- Linux or macOS:
pgrep -a ffmpeg,pgrep -a obs, andss -tnp | grep -E ':1935|:443' | headfor an open publish socket - Windows: Task Manager → Details, looking for a second
obs64.exeorffmpeg.exe - Restreaming dashboards, and any cron job or scheduled task that starts a stream
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.
- 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.
- Streamlabs: log out of the destination, reconnect it, then confirm it is enabled in the Go Live window.
- 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.
- YouTube: check for live streaming restrictions from Community Guidelines strikes, copyright, age rules or "made for kids" settings. Allow up to 24 hours on a channel that just enabled live, and note that YouTube's error list also has a daily limit on creating live streams that makes you wait 24 hours.
- Facebook: at least 60 days old, with 100 followers on the Page or professional-mode profile.
- Check your own role. An editor can stream but cannot reset a key, and a role change can quietly remove your access.
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:
- Connects and frames count up: the key is good. Your problem is the encoder, the scene or the broadcast you are watching.
- Prints a server error and exits in seconds: the publish was refused. Go back to fixes 1, 3, 4 and 8.
- Hangs or times out: network, port or TLS. Compare plain RTMP on 1935 against RTMPS on 443.
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
| Symptom | Most likely cause | Fix |
|---|---|---|
| Worked yesterday, refused today (Facebook) | Single-use key consumed when the broadcast ended | Persistent stream key (fix 4) |
| Worked last month, refused now (YouTube scheduled event) | Non-reusable key cleaned up after the event | Custom reusable or default key (fixes 1, 3) |
| Refused instantly with a server message | Key reset, wrong channel, or publishing blocked | Re-copy, check account status (fixes 1, 8) |
| Connects, drops, retries every few seconds | Two encoders on one key | Find the extra sender or reset (fix 6) |
| Never connects with any key | Port 1935 blocked, VPN, no RTMPS support | RTMPS on 443 (fix 5) |
| Works in FFmpeg, fails in OBS | Whitespace in the field, or a stale account token | Re-paste unmasked, or re-authorise (fixes 2, 7) |
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.
- Use persistent keys deliberately. YouTube's default or a named custom key; Facebook's persistent key, ticked on purpose. Never build a routine on a key that came with a one-off broadcast.
- Name your custom keys after the machine that uses them, like "Studio PC 1080p" or "Cloud loop", so each event's dropdown tells you what it is bound to.
- Keep one key per sender. A backup machine gets its own key or the platform's backup address, never a second copy of the primary key.
- Treat a reset as an incident. List every place the key lives first, then update them all in one pass.
- Never let a key reach a screenshot, tutorial, chat thread or Git repo. If it does, reset it the same day.
- Default to RTMPS. Encrypted, on 443, and it removes the whole class of blocked-port errors that masquerade as key problems.
- Keep the FFmpeg test command saved where you can find it in a hurry, and check the channel or Page selector before copying any key.
- Start the encoder five minutes early on anything scheduled, and review who has owner or manager access, since those are the people who can reset your key out from under you.
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.
Sources & official docs
- YouTube Help: Manage live stream settings
- YouTube Help: Create a live stream with an encoder
- YouTube Help: Live streaming error messages
- YouTube Help: Troubleshoot your live stream
- YouTube Help: Encrypt your stream using RTMPS
- YouTube Help: Restrictions on live streaming
- YouTube Live Streaming API: LiveStreams resource
- Meta for Developers: Live Video API
- Meta for Developers: Live Video API Getting Started
- Meta for Developers: Live Video API Best Practices
- OBS Forums: OBS cannot connect to YouTube - Stream Key error
- PRISM Live Studio Guide: Handling stream key or channel access issue


