I'm trying to get the basic voice agent working wi...
# ask-ai
l
I'm trying to get the basic voice agent working with a self hosted livekit server running locally but am unable to get the agent to connect to the server:
Copy code
uv run python src/agent.py dev
2025-08-14 13:20:02,364 - DEBUG asyncio - Using selector: EpollSelector 
2025-08-14 13:20:02,365 - DEV  livekit.agents - Watching /home/dsun/ai-panel-demo/backend/agent-starter-python/src 
2025-08-14 13:20:03,173 - DEBUG asyncio - Using selector: EpollSelector 
2025-08-14 13:20:03,176 - INFO livekit.agents - starting worker {"version": "1.2.5", "rtc-version": "1.0.12"}
2025-08-14 13:20:03,176 - INFO livekit.agents - preloading plugins {"packages": ["livekit.plugins.openai", "av"]}
2025-08-14 13:20:03,372 - WARNING livekit.agents - failed to connect to livekit, retrying in 0s 
Traceback (most recent call last):
  File "/home/dsun/ai-panel-demo/backend/agent-starter-python/.venv/lib/python3.12/site-packages/livekit/agents/worker.py", line 648, in _connection_task
    ws = await self._http_session.ws_connect(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dsun/ai-panel-demo/backend/agent-starter-python/.venv/lib/python3.12/site-packages/aiohttp/client.py", line 1084, in _ws_connect
    raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 400, message='Invalid response status', url='<ws://localhost:7880/agent>'
Additionally, my locally hosted instance of the agent playground is able to connect to the livekit server with no problem.
t
Thanks for reaching out, Derek. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Let’s get your LiveKit agent connected to your self-hosted server. Here are some friendly steps to walk through: 1. Check WebSocket URL: Double-check that the WebSocket URL (`ws://localhost:7880/agent`) is set up correctly and that it’s reachable. 2. Run Connection Tests: Try using a connection test tool to see if WebSocket and WebRTC connections are working smoothly. This can help spot any network or firewall hiccups. 3. Review Logs: Take a peek at the agent logs for any specific errors or connection attempts. That
400 Invalid response status
usually points to a WebSocket handshake issue. 4. Verify Authentication: Make sure your API keys and tokens are generated properly and included in the WebSocket connection headers. 5. Check Server Configuration: Confirm your self-hosted server is set up right, including firewall rules and that port 7880 is open. Since your agent playground connects just fine, it might help to compare its setup with your agent’s to spot any differences. If you want, I’m here to help with any of these steps or if you have questions. Just let me know! Sources: Agent Testing &amp; Evaluation | livekit/livekit_composite | DeepWiki | agents/src/worker.ts | Diagnosing Connection Errors with Connection Test Utility | Agents Overview | LiveKit Docs