How to Detect VPN Users in 2026: A Developer's Guide (JavaScript + Server)
By Mehmood Ali · · 15 min read
Code-first guide to spotting VPN, proxy, Tor and datacenter IPs: browser signals (WebRTC, timezone, language), server signals (ASN, JA3, RTT) and scoring.
This guide shows, with code, how to spot VPN, proxy, Tor and datacenter IPs on your own site. It starts with the JavaScript signals you can collect in the browser, moves on to what the server can read from the TCP and TLS stacks, and ends with a way to combine them that doesn't punish real users. Feel free to copy the example code.
Client-side signals to collect
1. Timezone vs claimed IP
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
// Send tz to your backend, which compares against
// the geo timezone of the request's IP.A browser reporting America/New_York from an IP geolocated to Frankfurt is a strong VPN tell. In practice the false-positive rate is below 1%. Travelers are the usual innocent explanation, and there aren't many of them.
2. Language preference
const lang = navigator.language;
const langs = navigator.languages;
// "en-US", ["en-US","en","fr"]
// Compare against the expected language for the IP's country.Language is less precise than timezone, but it helps back up other signals. Users in Taiwan reporting en-US are unremarkable, while a mainland user reporting en-US from a Shanghai IP is mildly suspicious.
3. WebRTC leak detection
async function tryWebRTCIP() {
const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
});
pc.createDataChannel("probe");
const seen = new Set();
pc.onicecandidate = (e) => {
if (!e.candidate) return;
const [, , , , ip, , typeKw, type] = e.candidate.candidate.split(" ");
if (typeKw === "typ" && type === "srflx" && ip) seen.add(ip);
};
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);
await new Promise((r) => setTimeout(r, 1500));
pc.close();
return [...seen][0];
}
// If the returned IP differs from the HTTP-layer source IP,
// the browser is behind a VPN that does not tunnel UDP.A WebRTC leak is one of the strongest VPN tells you can get on the client, because it exposes the real public IP the STUN server sees. Browsers now ship several mitigations (Firefox strict mode, Brave Shields, Chrome's WebRTC IP handling policy), so you won't always get a leak. When you do, it is close to conclusive.
4. Client-measured RTT (SNITCH)
// After a fetch completes, pull the timing entry
// and extract the TCP and TLS handshake RTTs.
const entries = performance.getEntriesByName(url);
const e = entries[entries.length - 1];
const tcpRttMs = e.secureConnectionStart - e.connectStart;
const tlsRttMs = e.connectEnd - e.secureConnectionStart;On a direct connection the TCP and TLS RTTs are close to equal, since both cross the same path. Through a VPN, the TLS handshake has to cross the tunnel while TCP only reaches the ingress, and the difference is measurable. That is the idea behind the SNITCH paper (NDSS 2025).
Server-side signals to collect
5. ASN / org classification
Every IP belongs to an Autonomous System. An IP in a datacenter ASN (AWS AS16509, Google AS15169, Microsoft AS8075, Hetzner AS24940, OVH AS16276, DigitalOcean AS14061) is a strong sign that the connection isn't coming from consumer home broadband. Do the lookups against a local IP-to-ASN database.
6. JA3 / JA4 TLS fingerprint
In Go with the dreadl0ck/ja3 package you can pull the JA3 hash out of the TLS ClientHello during the handshake and look it up in a database of known VPN fingerprints. Our JA3/JA4 deep dive explains how the hashes are built.
7. Tor exit list
// Refresh hourly
fetch("https://check.torproject.org/exit-addresses")
.then(r => r.text())
.then(t => {
const exits = new Set();
for (const line of t.split("\n")) {
if (line.startsWith("ExitAddress ")) {
exits.add(line.split(" ")[1]);
}
}
// store in your fast lookup cache
});Combining the signals
Give each signal a weight, add up the weights of the ones that match, and map the total to a verdict with thresholds like these:
| Score | Verdict | Recommended action |
|---|---|---|
| ≥ 0.85 | vpn_detected | Block or force step-up auth |
| 0.60–0.85 | vpn_likely | Soft friction (captcha, email verify) |
| 0.30–0.60 | suspicious | Log and monitor |
| < 0.30 | clean | Normal flow |
The shortcut: use IPLogs
You can build the pipeline above yourself. Or you can POST one JSON payload to the IPLogs API and get the verdict, score, confidence and full signal set back. It needs no signup or API key and is free within reasonable use.
curl -X POST https://iplogs.com/v1/check \
-H 'content-type: application/json' \
-d '{"ip":"45.82.245.81"}'The full API reference lists every signal and request field, with client examples in Python, Node.js, Go, PHP and Ruby.