# Troubleshooting

#### "Invalid or expired API key!"

**Possible Causes:**

* API key is incorrect (typo or copy/paste error)
* API key has extra spaces or characters
* YouTube Data API v3 not enabled
* API key restrictions too strict

**Solutions:**

1. **Verify API key is correct:**

```bash
   # Check for extra spaces
   /sl youtube setup AIzaSy...  # Wrong (space at end)
   /sl youtube setup AIzaSy...   # Wrong (extra spaces)
   /sl youtube setup AIzaSy...  # Correct (no extra spaces)
```

2. **Test API key manually:**

```
   https://www.googleapis.com/youtube/v3/search?part=id&maxResults=1&q=test&type=video&key=YOUR_KEY
```

* If this works in browser, key is valid
* If it fails, regenerate the key

3. **Check API is enabled:**
   * Go to [APIs & Services → Library](https://console.cloud.google.com/apis/library)
   * Search "YouTube Data API v3"
   * Ensure it says "Manage" (not "Enable")
4. **Check API restrictions:**
   * Go to APIs & Services → Credentials
   * Click your API key
   * Verify "API restrictions" includes "YouTube Data API v3"
   * If "Application restrictions" is set, try "None" temporarily
5. **Regenerate API key:**
   * Delete the old key in Google Cloud Console
   * Create a new one following Step 3
   * Update StreamLink: `/sl youtube setup <new_key>`

***

#### "No active live stream found. You must be currently streaming..."

**Possible Causes:**

* You're not actually streaming yet
* Stream is scheduled but not started
* Stream just started (not fully initialized)
* Stream must be "**Public**"
* Channel ID is incorrect

**Solutions:**

1. **Verify you're streaming:**
   * Go to [YouTube Studio](https://studio.youtube.com/)
   * Check that your stream shows as "Live" (not "Scheduled")
   * Stream indicator should be red/active
2. **Wait for stream to initialize:**
   * After clicking "Go Live", wait 30-60 seconds
   * Stream needs time to fully start
   * Try connecting again after waiting
3. **Check your Channel ID:**

```bash
   # Verify it's correct (24 chars starting with UC)
   /sl youtube set UCa1b2c3d4e5f6g7h8i9j0k1l2m3n
```

* Go to YouTube Studio → Settings → Channel → Advanced
* Compare with your configured Channel ID
* Update if different

4. **Check stream visibility:**
   * StreamLink works with Public and Unlisted streams
   * Private streams are not tested/supported
5. **Try manual search:**
   * Open your channel in a browser
   * Look for the "Live" indicator
   * If not visible, stream isn't active yet

***

#### "Live chat is not enabled on your current stream."

**Possible Causes:**

* Chat is disabled in stream settings
* Chat was disabled mid-stream
* Stream type doesn't support chat

**Solutions:**

1. **Enable chat in stream settings:**
   * Go to [YouTube Studio](https://studio.youtube.com/) → Live dashboard
   * Click on your active stream
   * Scroll to "Chat" section
   * Ensure **"Enable chat"** is checked
   * Click "Save"
2. **Check stream type:**
   * Regular live streams support chat
   * Some mobile live streams may have chat disabled
   * Verify stream is set up correctly
3. **Restart the stream (if needed):**
   * If chat was disabled, enabling it may require stream restart
   * End current stream
   * Start new stream with chat enabled
   * Reconnect StreamLink
4. **Verify chat is visible:**
   * Open your stream in a browser
   * Confirm you can see the chat panel
   * Try sending a test message manually

***

#### "Already connected!"

**Cause:** You're already connected to YouTube chat

**Solution:**

```bash
# Disconnect first, then reconnect
/sl youtube disconnect
/sl youtube connect
```

***

#### Messages Not Appearing

**Possible Causes:**

* Polling hasn't occurred yet (wait 5-10 seconds)
* Connection dropped silently
* API quota exceeded
* Network issues

**Solutions:**

1. **Wait for polling cycle:**
   * Messages appear every \~5 seconds
   * Wait at least 10 seconds after connecting
2. **Check connection status:**

```bash
   # Open dashboard to check status
   /sl ui
```

* Status should show a green dot (connected)
* If red, reconnect: `/sl youtube connect`

3. **Try full reconnect:**

```bash
   /sl youtube disconnect
   /sl youtube connect
```

4. **Check API quota:**
   * Go to Google Cloud Console → APIs & Services → Dashboard
   * Click "YouTube Data API v3"
   * Check "Queries per day" usage
   * If at 100%, you've exceeded quota
5. **Check server console:**
   * Look for `[YouTube]` error messages
   * Look for `[YouTubeAuth]` validation messages
   * Report errors to GitHub Issues if persistent

***

#### API Quota Exceeded

**Cause:** You've used all 10,000 API units for the day

**Immediate Solutions:**

1. **Wait for quota reset:**
   * Quota resets at midnight Pacific Time (PT)
   * Check current quota in Google Cloud Console
2. **Disconnect to stop usage:**

```bash
   /sl youtube disconnect
```

**Long-Term Solutions:**

1. **Request quota increase:**
   * Go to [Google Cloud Console](https://console.cloud.google.com/)
   * Navigate to APIs & Services → Quotas
   * Find "YouTube Data API v3" → "Queries per day"
   * Click pencil icon → "Request quota increase"
   * Fill out form with justification
   * Google typically responds in 1-3 days
2. **Create multiple projects:**
   * Each Google Cloud project has its own quota
   * Create additional projects for more daily quota
   * Switch between API keys as needed
3. **Optimize streaming schedule:**
   * Disconnect immediately when ending stream
   * Avoid test connects when not streaming
   * Stream during off-peak hours if shared quota

***

#### Connection Drops/Disconnects

**Possible Causes:**

* Stream ended
* Network issues
* API errors
* Server restart

**Solutions:**

1. **Check stream status:**
   * Verify stream is still live
   * If ended, restart stream and reconnect
2. **Reconnect manually:**

```bash
   /sl youtube connect
```

3. **Check server logs:**
   * Look for error messages in console
   * Note any `[YouTube]` error patterns
4. **Verify network connectivity:**
   * Test server internet connection
   * Check firewall isn't blocking YouTube API
   * Verify DNS resolution works


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kentatetsu.gitbook.io/streamlink/guides/youtube-setup-guide/troubleshooting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
