Blog
Detect VPN and proxy traffic in Node.js: Tor lists, hosting networks and an API check
Detect VPN, proxy, Tor and data center traffic in Node.js: build local signals from the Tor exit list and ASN data, add an API check, and turn them into friction.
Updated 2026-11-25
To detect VPN and proxy traffic in Node.js, look up the client IP address on your server and collect four signals: is it a Tor exit node, does it belong to a hosting network, does it belong to a known VPN service, and does it belong to a known proxy service. The first two you can build yourself with two free datasets. The last two need curated network lists, which is where an API helps. None of them proves intent, so the output of this post is a friction level, not a block.
VPN detection explains how each signal is built and what it misses, without code. This post is the Node.js implementation.
What you can detect, and what you cannot
| Signal | How | Catches | Misses |
|---|---|---|---|
| Tor | The Tor Project's exit list | Every published Tor exit node | Tor bridges used to reach the network, which are not exits |
| Hosting network | ASN lookup plus a list of hosting providers | Scripts, scrapers, many VPN servers | Providers missing from your list |
| VPN service | Networks registered to known VPN services | Commercial VPNs on their own networks | VPNs hidden in hosting or residential networks |
| Proxy service | Networks registered to known proxy services | Commercial proxy networks | Residential proxies |
The last row is the important one. Residential proxies route traffic through home connections, and no IP list can tell them from the real customers of the same ISP.
Read the right client address
Every check depends on the address you send. Behind a load balancer or CDN, the TCP connection comes from the proxy.
- In Express,
app.set('trust proxy', 1)trusts one proxy hop and makesreq.ipthe client address. Set the number to the hops you control. - Behind Cloudflare, read
CF-Connecting-IP. - Never read
X-Forwarded-Fordirectly when your server can be reached without the proxy: anyone can send it. - Node reports IPv4 clients on dual-stack sockets as
::ffff:1.2.3.4. Strip the prefix before comparing with lists of IPv4 addresses.
Build local signals
Two free datasets give you Tor and hosting signals without any API.
- The Tor exit list. The Tor Project publishes the current exit addresses at
https://check.torproject.org/torbulkexitlist, one address per line. On 2026-11-25 it held 1,257 addresses. Refresh it every hour, since exits come and go. - An ASN database. DB-IP's free IP to ASN Lite database maps each address to its autonomous system, the network that announces it on the internet. It comes as an
.mmdbfile, is updated monthly and is licensed under Creative Commons Attribution 4.0, which requires attribution to DB-IP.com.
npm install maxmind lru-cache express
curl -sS https://download.db-ip.com/free/dbip-asn-lite-2026-11.mmdb.gz | gunzip > dbip-asn-lite.mmdb
import maxmind from 'maxmind'
const TOR_LIST_URL = 'https://check.torproject.org/torbulkexitlist'
const HOSTING_ASNS = new Set([
16509, 14618, 15169, 396982, 8075, 14061, 16276, 24940, 63949, 20473, 31898, 45102,
])
const asnReader = await maxmind.open('./dbip-asn-lite.mmdb')
let torExits = new Set()
export async function refreshTorExits() {
const response = await fetch(TOR_LIST_URL, { signal: AbortSignal.timeout(10000) })
if (!response.ok) return
const lines = (await response.text()).split('\n').map((line) => line.trim())
const addresses = lines.filter((line) => line && !line.startsWith('#'))
if (addresses.length > 0) torExits = new Set(addresses)
}
await refreshTorExits().catch(() => {})
setInterval(() => refreshTorExits().catch(() => {}), 60 * 60 * 1000).unref()
export function localSignals(ip) {
const address = ip?.startsWith('::ffff:') ? ip.slice(7) : ip
const network = address && maxmind.validate(address) ? asnReader.get(address) : null
const asn = network?.autonomous_system_number ?? null
return {
tor: torExits.has(address),
hosting: asn !== null && HOSTING_ASNS.has(asn),
asn,
org: network?.autonomous_system_organization ?? null,
}
}
The HOSTING_ASNS set is a starting list of large cloud and hosting networks: Amazon (16509, 14618), Google (15169) and Google Cloud (396982), Microsoft (8075), DigitalOcean (14061), OVH (16276), Hetzner (24940), Akamai's Linode (63949), Vultr (20473), Oracle Cloud (31898) and Alibaba (45102). We checked each number against its registered AS name in the RADb routing registry. Match on numbers rather than on organization names: a name match on "google" would also flag Google Fiber, a consumer ISP on its own AS.
Two details in the code matter. A failed refresh keeps the previous Tor list instead of emptying it. And .unref() stops the timer from keeping a script or a test runner alive.
We ran localSignals with maxmind 5.1.0 and the November 2026 file:
| Address | Result |
|---|---|
81.2.69.142 |
AS20712, Andrews & Arnold Ltd, no flag |
13.37.0.1 |
AS16509, Amazon.com, Inc., hosting |
2a01:4f8::1 |
AS24940, Hetzner Online GmbH, hosting |
| A line of the Tor list | tor |
127.0.0.1, ::1 |
No network, no flag |
What the local version cannot do: name VPN and proxy services. Those run on dozens of smaller networks, rename and move, and keeping that list current is a job of its own.
Add the API check
The Qelka IP endpoint returns the same Tor and hosting signals plus the VPN and proxy flags, a network type and a risk score. Cache it per address so a busy client costs one lookup an hour, and fail open so an outage never blocks signups.
import { LRUCache } from 'lru-cache'
const cache = new LRUCache({ max: 50000, ttl: 60 * 60 * 1000 })
export async function apiSignals(ip) {
const cached = cache.get(ip)
if (cached) return cached
let result
try {
const response = await fetch('https://api.qelka.com/v1/ip', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ ip }),
signal: AbortSignal.timeout(3000),
})
if (!response.ok) return { level: 'unknown' }
result = await response.json()
} catch {
return { level: 'unknown' }
}
const signals = {
level: result.risk.level,
score: result.risk.score,
tor: result.flags.tor,
vpn: result.flags.vpn,
proxy: result.flags.proxy,
hosting: result.flags.datacenter,
networkType: result.asn?.type ?? 'unknown',
country: result.country?.code ?? null,
}
cache.set(ip, signals)
return signals
}
Private, loopback and documentation addresses return 422 unprocessable_input, which is not billed, and the function turns it into unknown. That is what you get in local development.
| Field | Meaning |
|---|---|
flags.tor |
The address is on the Tor Project's exit list |
flags.vpn |
The network is registered to a known VPN service |
flags.proxy |
The network is registered to a known proxy service |
flags.datacenter |
asn.type is hosting |
asn.type |
hosting, isp, mobile, business, education, government or unknown |
risk.level |
low under 30, medium from 30 to 69, high from 70 |
A Tor exit node or a proxy reaches high on its own, and a VPN or a data center alone gives medium. IP risk score lists the weight of every signal. Each lookup costs 1 credit, and a sk_test_ key maps the documentation ranges to fixed profiles, so you can test every branch for free: 198.51.100.10 is the simulated VPN. See test mode and the IP API reference.
Turn signals into friction
A flag is evidence, not a verdict. Office VPNs, privacy tools, cloud desktops and travelers all trip it. Map the signals to a step that costs a real person a few seconds and a fraudster a lot more.
import express from 'express'
import { localSignals } from './ip-signals.js'
import { apiSignals } from './api-signals.js'
function frictionFor(signals) {
if (signals.tor) return 'review'
if (signals.level === 'high') return 'verify'
if (signals.hosting || signals.vpn || signals.proxy || signals.level === 'medium') return 'verify_before_rewards'
return 'none'
}
const app = express()
app.set('trust proxy', 1)
app.use(express.json())
app.post('/signup', async (req, res) => {
const local = localSignals(req.ip)
const remote = await apiSignals(req.ip)
const signals = { ...local, ...(remote.level === 'unknown' ? {} : remote) }
const friction = frictionFor(signals)
console.log(JSON.stringify({ event: 'signup_ip_signals', friction, signals }))
res.json({ friction })
})
app.listen(3000)
When the API answers, its flags replace the local ones. When it does not, the local Tor and hosting signals still apply, so the check degrades instead of disappearing. We ran this route locally with the API unreachable: an Andrews & Arnold address got none, an Amazon address got verify_before_rewards, a Tor exit got review and localhost got none.
| Friction | What to do |
|---|---|
none |
Let the person through |
verify_before_rewards |
Create the account, hold trial credits, coupons or referral rewards until the email is confirmed |
verify |
Confirm the email or phone number before the account becomes active |
review |
Send the account to manual review, or apply your Tor policy |
Tor deserves its own decision. Some services welcome Tor users on purpose; others see mostly abuse from it. Write the policy down and apply it through the tor flag.
Run it in shadow mode first
Log the friction level for two weeks without acting on it. Then compare it with what happened to those accounts: chargebacks, abuse reports, accounts that never confirmed. You will find which signals predict trouble on your traffic and which only annoy customers. A B2B product whose buyers sit behind corporate gateways will tune this very differently from a consumer app with free credits.
Things to look for in the logs:
- Hosting traffic from integrations. API clients, uptime monitors and server-side webhooks come from data centers on purpose. Exempt known routes and keys.
- Mobile networks. Many users share each address behind carrier-grade NAT, so never block an
asn.typeofmobileon its own. - Apple iCloud Private Relay. Apple publishes its egress ranges at
https://mask-api.icloud.com/egress-ip-ranges.csv. Traffic from them is a privacy feature of a consumer device, not a sign of fraud.
Mistakes that cost the most
- Blocking on a single flag. You lose real customers and teach fraudsters which flag to avoid.
- Calling the API from the browser. The key leaks, and the browser cannot see its own public address anyway.
- Looking up every request. Look up the moments that matter, such as signup, login from a new device and checkout, and cache the rest.
- Trusting
X-Forwarded-Foras sent. Configuretrust proxyinstead. - A stale Tor list. Refresh it hourly, and keep the old one when a refresh fails.
The flag VPN and data center traffic guide has the same flow in Python with Flask. Check single addresses with the free VPN and proxy detection and ASN lookup tools, read IP fraud score for how a score adds up, and see detect VPN and proxy users for a no-code walkthrough.
Frequently asked questions
How do I detect if a visitor uses a VPN in Node.js?
Can I detect a VPN from the browser with JavaScript?
Is a data center IP address the same as a VPN?
Can residential proxies be detected by IP?
Keep going
- Free toolVPN and proxy detectionCheck an IP address against Tor exit lists, data center networks and known VPN providers.Try it
- APIVPN and proxy detectionTor, data center, VPN and proxy flags with a risk score for any public IP.See the API
- ArticleVPN detection: spotting VPNs, proxies, Tor and data center traffic at signupHow VPN, proxy, Tor and data center detection works from an IP address, what it misses, and how to add friction at signup without turning real users away.Read
- ArticleResidential proxies: the traffic an IP check cannot see, and what to watch insteadWhat residential proxies are, why they pass IP checks, where their addresses come from, and the account-level signals that still expose automated abuse.Read
Put this check in your product
Get an API key in under a minute. 100 free credits every month, no card required.
- 100 free credits a month
- No card
- Test keys spend nothing
- Cancel any time