How to Detect VPN and Proxy Users

Identify VPN, proxy, and datacenter IPs to prevent fraud and enforce geo-restrictions. Complete tutorial with code examples.

Article featured image

Should you block a user just because they’re on a VPN? Probably not. But should you ignore it entirely? Also no.

VPNs create a real paradox: privacy-conscious users and fraudsters look identical at the network level. Both show up as traffic from an IP that isn’t the user’s real location. The question isn’t whether VPN users are good or bad—it’s what you do with that signal.

What VPN Detection Actually Tells You

When you detect a VPN, you learn one thing with certainty: the IP address you see isn’t where the user physically sits. Everything else is inference.

This matters because IP-based assumptions underpin many security and business decisions. Geo-restrictions assume the IP reflects the user’s country. Fraud scoring assumes the IP reflects the user’s typical location. Abuse prevention—often paired with an IP lookup for location context—assumes the IP can identify repeat offenders.

VPN detection doesn’t tell you the user is malicious. It tells you that your IP-based assumptions might be wrong. That’s valuable information, but it requires nuance in how you respond.

Not All Hidden IPs Are Created Equal

Not all IP masking is equal, and treating it that way is one of the most common mistakes teams make.

Consumer VPNs are the most common. Services like NordVPN, ExpressVPN, and Surfshark provide privacy for everyday users. Someone on a consumer VPN might be protecting themselves on public WiFi, bypassing regional content restrictions, or just valuing privacy generally. Consumer VPN usage alone is a weak fraud signal.

Datacenter IPs are more concerning. When traffic comes from AWS, Google Cloud, or DigitalOcean, it’s almost never a regular user browsing from their laptop. Datacenter IPs typically indicate automation—bots, scrapers, or programmatic access. A bot detector can help distinguish legitimate automation from malicious automation.

Tor exit nodes represent the strongest anonymity. Tor users have deliberately chosen a system designed to make tracing impossible. While Tor has legitimate uses (journalists in authoritarian countries, whistleblowers, privacy advocates), it’s also the tool of choice for serious bad actors. Tor traffic warrants the highest scrutiny.

Residential proxies are the hardest to detect. These route traffic through real residential IP addresses, making it appear as normal consumer traffic. They’re expensive and primarily used for sophisticated operations—either legitimate (price comparison, ad verification) or illegitimate (credential stuffing, sneaker bots).

If you take one thing from this section: the type of masking matters far more than the fact of masking.

The Problem with Blocking

Many developers’ first instinct is to block VPN users entirely. This seems logical—if VPNs enable fraud, just prevent VPN access.

In practice, blanket blocking creates more problems than it solves. You’ll block:

Privacy-conscious professionals who use corporate VPNs for work and leave them connected during personal browsing. Travelers who use VPNs for security on hotel and airport networks. Users in countries where VPNs are necessary for accessing uncensored internet. Security researchers and journalists who have legitimate reasons for anonymity.

Each blocked legitimate user is a lost customer and a support ticket. At scale, this friction compounds into significant business impact.

And here’s the frustrating part: determined fraudsters will find ways around your blocks anyway. They’ll use residential proxies you can’t detect. They’ll rotate through IPs until they find ones you haven’t flagged. Blocking stops the casual abusers while the sophisticated ones—the ones causing real damage—adapt and continue.

Risk Scoring Instead of Blocking

The mature approach treats VPN detection as one signal among many. VPN usage adds points to a risk score. Other signals add more points. High-risk combinations trigger friction or review.

Consider this framework:

A new account signing up from a consumer VPN with a valid email address? Low additional risk. Might just be a privacy-conscious user.

A new account from a datacenter IP with a disposable email address? Moderate risk. The combination is suspicious even if neither signal alone would be.

A new account from a datacenter IP, disposable email, making a high-value purchase with expedited shipping to an address different from the billing address? High risk. This pattern matches known fraud behavior.

The VPN signal contributes to the assessment but doesn’t determine it alone. This is the part most teams skip—building the scoring model—and it’s also the part that actually works.

Geo-Restriction Enforcement

Some applications must enforce geographic restrictions. Streaming services have content licensed only for specific countries. Online gambling sites must comply with jurisdictional regulations. Financial services face different rules in different regions.

VPN detection becomes more important here because users actively try to circumvent restrictions. Someone in Germany using a US VPN to access US-only content is intentionally violating the restriction. Unlike fraud prevention, where VPN usage is an indirect signal, geo-restriction enforcement directly cares whether the stated location is real.

Even here, blanket blocking has drawbacks. A US user traveling abroad might use a VPN to access their US-based services. They’re not circumventing restrictions—they’re maintaining access to services they legitimately subscribe to from their home country.

The cleanest approach is transparency. Tell users that VPN access is restricted and why. Offer them the option to disable their VPN and retry. This respects their choice while maintaining compliance.

The Datacenter IP Signal

Datacenter IPs deserve special attention because they’re almost never legitimate consumer traffic. Regular users browse from home connections, mobile networks, or corporate networks—not from cloud servers.

When you see traffic from a datacenter IP, you’re likely seeing:

Bots and scrapers. Automated systems that collect data, test credentials, or interact with your application programmatically.

Proxy services. Some proxy services route traffic through datacenter infrastructure rather than residential IPs.

Legitimate automation. Monitoring services, integration testing, webhook deliveries. These are valid but should probably be authenticated differently than user traffic.

The response to datacenter traffic can be stricter than the response to consumer VPNs. Rate limiting is almost always appropriate. Additional authentication challenges are reasonable. For high-risk operations like account creation or purchase completion, requiring a non-datacenter IP is defensible.

Implementation Patterns

The technical implementation is straightforward. Check the user’s IP against a VPN detection API on requests where you need the information—typically authentication, checkout, and account creation endpoints.

const response = await fetch(
  `https://api.apiverve.com/v1/vpndetector?ip=${clientIp}`,
  { headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await response.json();

// data.is_vpn - boolean, is this a VPN exit node?
// data.is_datacenter - boolean, is this a cloud/hosting IP?
// data.risk_level - string, overall risk assessment

Cache results by IP address. VPN status doesn’t change frequently—an hour TTL is reasonable. This reduces API calls and latency for repeat visitors.

Attach the results to the request context so downstream code can access it. Your fraud scoring, rate limiting, and access control logic can all reference the same detection data without redundant API calls.

What Not to Do

A few anti-patterns to avoid:

Don’t show accusatory messages. Seriously, don’t. “We detected you’re using a VPN” sounds like an accusation. Users who aren’t doing anything wrong will be offended. Users who are doing something wrong won’t be deterred.

Don’t rely solely on VPN detection for security. It’s one signal. Sophisticated attackers use residential proxies, compromised consumer devices, and other techniques that evade detection.

Don’t log VPN status with personally identifiable information. This creates a record that could be subpoenaed or breached. Log aggregate statistics if you need them for analysis.

Don’t update your detection database infrequently. VPN providers constantly add new exit nodes. Tor exit nodes rotate regularly. Your detection needs fresh data to stay accurate.

Measuring Effectiveness

Track the impact of VPN detection on your fraud and abuse metrics. Are you catching more bad actors? Are you creating friction for legitimate users?

Monitor false positive rates by correlating VPN detection with downstream outcomes. If accounts flagged for VPN usage have the same fraud rate as unflagged accounts, your threshold might be wrong.

Compare chargebacks and abuse reports between VPN and non-VPN traffic. If VPN users have higher rates of problematic behavior, your detection is providing useful signal. If rates are similar, you might be adding friction without benefit.

Keep Reading


Detect VPNs and proxies with the VPN Detector API. Identify Tor exit nodes with the Tor Detector API. Get complete IP intelligence with the IP Lookup API. Build smarter risk assessment.

Ready to start building?

Access {apiCount} APIs and start building amazing applications today.

Get Started Free