Gemini 2.0 Multimodal error 1007: 'User location not supported' suddenly on Ubuntu server, but works on Windows server in the same location

Hello!
I’ve been using the google-genai library (Gemini 2.0 Multimodal Live API) on an Ubuntu server in France. It worked fine for a while, but one day it suddenly started failing with a WebSocket error 1007 and this message:

[ORIGINAL ERROR] generic::failed_precondition: User location is not supported for the A

The exact same code, environment, Python version, and API key on a Windows server in the same location works perfectly. I’ve checked firewall settings, system time, certificates, etc., but no luck.

Does anyone know why an identical setup in the same region would suddenly be blocked on the Ubuntu server but still work on the Windows server? Any insights or workarounds would be greatly appreciated!

Hey, I saw this right away! Here’s a practical solution to resolve the location access issue:

export GOOGLE_CLOUD_LOCATION="us-central1"

You can also try using a VPN endpoint in a fully supported region like US or UK. The difference between Windows and Ubuntu behavior likely stems from how each OS handles geolocation services. Setting an explicit location or routing through a supported region should resolve the access restriction.

For a permanent fix, add the location variable to your .bashrc or deployment configuration.

should i do like this?

> import os
> os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1"
> 
> import asyncio
> import logging
> import sys
> from google import genai
> 
> logging.basicConfig(
>     level=logging.INFO,
>     format="%(asctime)s [%(levelname)s] %(message)s"
> )

I still get same error, and vpn is unacceptable, because i using audio live streming, need lowest delays.

Also i have used USA vps before, it says user location is not supported too

Yes, your code structure is good! Here’s an enhanced version that often works better:

import os
os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1"
os.environ["GOOGLE_CLOUD_REGION"] = "us-central1"

import asyncio
import logging
import sys
from google import genai

logging.basicConfig(
    level=logging.DEBUG,  # Changed to DEBUG for more detailed logs
    format="%(asctime)s [%(levelname)s] %(message)s",
    handlers=[logging.StreamHandler(sys.stdout)]
)

Since VPN isn’t an option, try these alternatives:

  1. Use a different API endpoint region
  2. Contact Google Cloud support with your project ID
  3. Verify your API key has the correct permissions and regional settings

The service is actively expanding to new regions, so keep checking the official documentation for updates.

If you are not sure with my answers, then maybe this will work:

or: