Gemini API HTTP 403 from VPS, but HTTP 200 from macOS — possible datacenter IP restriction

Hi Google AI Developers Community,

I’m developing HOMIX, a Swiss AI-powered platform for beauty salons. Our AI assistant uses the Gemini API to communicate with customers, provide consultations, and assist with appointment management.

We are experiencing persistent HTTP 403 Forbidden errors when sending Gemini API requests from our Linux VPS hosted in a Netherlands datacenter.

The issue is preventing us from reliably operating our AI assistant and completing our production readiness testing.

Technical environment

  • Backend: Python / FastAPI

  • Operating system: Ubuntu Linux

  • Infrastructure: Third-party VPS hosted in the Netherlands

  • Model tested: gemini-2.5-flash

  • Authentication: Gemini API key

  • Google API billing: Paid API usage enabled

Diagnostic results

Environment Result
Linux VPS HTTP 403 Forbidden
macOS development machine HTTP 200 OK
Google Cloud Shell (Vertex AI inference) Successful
Google Cloud Run Authenticated connectivity investigated separately

On the VPS:

  • Model-listing requests returned HTTP 403.

  • Content-generation requests also returned HTTP 403.

  • Some responses were Google-generated HTML error pages instead of standard JSON API responses.

  • No application-level HTTP proxy was configured during our diagnostics.

The same API connectivity tests succeeded from our macOS development environment.

Our VPS hosting provider suggested that the datacenter IP address might be restricted by Google, but could not confirm this.

Questions

  1. Could Google network-level security systems block legitimate Gemini API traffic originating from certain datacenter IP ranges?

  2. How can we distinguish an IP/network restriction from API-key, project, billing, or regional restrictions?

  3. Is there an official process to request a review of a potentially restricted VPS IP address?

  4. Are HTML 403 error responses expected when Google security systems reject requests before they reach the Gemini API?

  5. What additional diagnostics would help identify the root cause?

  6. Is there a recommended supported architecture for reliable Gemini API access from a third-party VPS?

We would prefer to resolve the root cause rather than migrate our entire production infrastructure based on an unconfirmed hypothesis.

I can provide sanitized HTTP response details, request timestamps, and additional diagnostics if needed.

Any guidance from Google engineers or developers who have encountered similar behavior would be greatly appreciated.

Thank you!

Receiving Google-generated HTML 403 pages answers your core question directly: traffic that reaches generativelanguage.googleapis.com returns application/json (PERMISSION_DENIED) even with no API key at all. A text/html 403 confirms Google Front End (GFE) or an upstream network edge is blocking requests before API-key, project, or billing checks ever run.

On the Netherlands VPS, compare IPv4, IPv6, and an unauthenticated call while reading the response headers (Content-Type, Server):

curl -i -s --max-time 10 -4 "https://generativelanguage.googleapis.com/v1beta/models" -H "x-goog-api-key: $GEMINI_API_KEY" | head -n 20
curl -i -s --max-time 10 -6 "https://generativelanguage.googleapis.com/v1beta/models" -H "x-goog-api-key: $GEMINI_API_KEY" | head -n 20
curl -i -s --max-time 10 "https://generativelanguage.googleapis.com/v1beta/models" | head -n 15

Shared VPS /64 IPv6 prefixes often trigger geo or abuse filtering at GFE while IPv4 passes cleanly. If -4 returns 200 OK and -6 fails (or -6 returns network-unreachable while -4 succeeds), preferring IPv4 in /etc/gai.conf (precedence ::ffff:0:0/96 100) fixes Python/httpx immediately without code changes.

If both -4 and the keyless check return HTML 403, that VPS subnet itself is restricted at GFE. Google’s Report IP Problems form targets geolocation errors, takes a month or more with no status email, and will not urgently unblock a shared datacenter ASN. Keep FastAPI on your VPS and point only Gemini calls at Vertex AI (aiplatform.googleapis.com in europe-west1 via a GCP service account) or a tiny Cloud Run egress proxy.

Hello ,

Thank you for sharing these details. Could you please share the full HTTP status code, response headers, and response body (with your API key redacted) from a failing request on your VPS, along with the approximate timestamp and your Project ID via Google AI Developer Forum: Share Details About Your Issue so we can look into this?