#Received network error or non-101 status code
1 messages · Page 1 of 1 (latest)
Hey there! This channel allows you to ask Kapa.ai for assistance. But it looks like you haven't connected your Discord profile to your Deepgram account yet. You can do so at https://community.deepgram.com - by doing so, you'll be able to ask questions in #1115960287183511643 if you need human assistance!
Deepgram’s community offers tons of resources to support you on your voice AI journey
Hi @kindred parrot. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
When you see “network error or non-101 status code” while connecting to Deepgram over WebSockets, it means the HTTP upgrade to WebSocket failed. A successful Deepgram streaming connection must return HTTP 101 Switching Protocols; anything else (e.g., 400, 401, 5xx) is an error. [STT WS basics; TTS WS basics]
To debug:
-
Check the actual HTTP status and headers
- Deepgram returns:
dg-request-idon all requests.dg-erroron failed upgrades with a human-readable error. [STT WS errors; TTS WS errors]
- Your WebSocket client or SDK should expose these; log them so you can see why the upgrade failed.
- Deepgram returns:
-
Common causes of non‑101 responses
- 401 Unauthorized – invalid or missing API key, or wrong auth header. [401 example]
- 400 Bad Request – invalid parameters (e.g., model not available, wrong base URL for self‑hosted). [Self‑hosted .NET]
- Other
4xx/5xx– treat as HTTP errors and handle/retry appropriately. [HTTP errors]
-
Minimal test to confirm connectivity
import websockets import asyncio import json
async def main():
try:
async with websockets.connect(
"wss://api.deepgram.com/v1/listen",
extra_headers={"Authorization": "token YOUR_DEEPGRAM_API_KEY"},
) as ws:
print("Connected, request ID:", ws.response_headers["dg-request-id"])
await ws.send(json.dumps({"type": "CloseStream"}))
except websockets.exceptions.InvalidStatusCode as e:
# Failed upgrade: inspect Deepgram headers
print("Failed to connect")
print("Status:", e.status_code)
print("dg-error:", e.headers.get("dg-error"))
print("dg-request-id:", e.headers.get("dg-request-id"))
asyncio.run(main())
This pattern is from the official troubleshooting docs and shows how to surface `dg-error` and `dg-request-id`. [[STT WS errors](<https://developers.deepgram.com/docs/stt-troubleshooting-websocket-data-and-net-errors#common-websocket-errors>)]
4. **Next step**
- Run a small test like above (or the equivalent in your language/SDK).
- Share the **HTTP status**, **`dg-error`**, and **`dg-request-id`**; that message will usually say exactly what’s wrong (auth, params, etc.).
If you paste the exact status code and any `dg-error` text you’re seeing, I can help interpret it more specifically.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------