Troubleshooting

TikTok LIVE connector "only works with VPN"

Your TikTok LIVE script "only works when turn on vpn": it connects over a VPN or mobile data, but on your normal Wi-Fi or server network it fails, often with "Websocket connection failed". Changing DNS (for example to 1.1.1.1) does not help.

Updated 2026-10-31

The error

Websocket connection failed, Error: Unexpected server response: 200
# works on VPN or mobile data, fails on the usual network

What it means

The open-source libraries open the WebSocket from your own machine to TikTok. Whether that works can depend on the network you connect from, so the same code can succeed on mobile data and fail on Wi-Fi.

Users in issue #329 reported that switching DNS did not help, while mobile data worked.

In issue #329 these reports came in at the same time as the September 2026 sign API change, so check the version first.

Fix it in the library

  1. Upgrade first: npm install tiktok-live-connector@latest (2.5.0 or later) or pip install -U TikTokLive (7.0.1 or later). See the September 2026 guide below.
  2. If one network works and another does not, route the library through the working one. TikTok-Live-Connector accepts a proxy agent through webClientOptions and wsClientOptions (see "Proxied Connection" in its README); TikTokLive accepts web_proxy and ws_proxy (both httpx.Proxy).
  3. On a server, test from the same host with the latest version before you change code, so you know whether the network or the version is the cause.

Or use the hosted API

The TikTools Node SDK has a relayed mode: events come from wss://api.tik.tools, so your process does not open a connection to TikTok from your own network. The Python SDK connects to wss://api.tik.tools by default. This is the script from the run on 2026-10-31:

npm install @tiktool/live
const { TikTokLive } = require('@tiktool/live');

const connection = new TikTokLive({
  uniqueId: process.argv[2] || 'username',
  apiKey: process.env.TIKTOOL_API_KEY || 'YOUR_API_KEY',
  mode: 'relayed', // events come from wss://api.tik.tools, not from your network to TikTok
});

connection.on('connected', () => console.log('Connected'));
connection.on('chat', data => console.log(`${data.user.uniqueId}: ${data.comment}`));
connection.on('gift', data => console.log(`${data.user.uniqueId} sent ${data.giftName}`));
connection.on('disconnected', (code, reason) => console.log(`Disconnected ${code} ${reason}`));

connection.connect().catch(err => console.error('Failed to connect:', err.message));

Python: pip install tiktok-live-api. Side-by-side code for both languages and the full event name map are in the migration guide. Plans and connection limits are on the pricing page; Sandbox is a 7-day evaluation, no credit card.