Gemini IP error: User location is not supported for the API use.

Posted by caique in general.

Hello, My server is hosted on node FREE EU RO 35 , located in Romania. Since yesterday, requests to the Google Gemini API have been failing with the following error: The same application works correctly on my local computer using the same API key and model. Restarting the server did not resolve the issue. Could you please check the public outbound IP address used by my server when connecting to the Google Gemini API? I would also like to know whether there have been any recent changes to the server's outbound IP or network configuration. Romania is listed as a supported region for the Gemini API, so I suspect the issue may be related to the geolocation or classification of the server's outbound IP address. If possible, could you provide a different outbound IP address for testing? Thank you for your help.

Replies

markkong30

My server FREE EU RO 37 is experiencing the same issue. Any help would be much appreciated!

caique

Workaround that worked for me: Cloudflare Workers relay Hi! I was experiencing exactly the same issue on Wispbyte's Romanian nodes. My application worked locally with the same Gemini API key and model, but the server returned: 400 FAILED PRECONDITION: User location is not supported for the API use. I also tested another Wispbyte server with a different IP address, but that one returned a generic Google HTML 403 Forbidden error. I found a workaround that worked for me: using a Cloudflare Worker as a relay between my application and the Gemini API. After setting it up, I ran three tests directly from my Wispbyte server: GET /v1beta/models → HTTP 200 POST generateContent without tools → HTTP 200 POST generateContent with the url context tool → HTTP 200 All three requests failed when sent directly from Wispbyte, but succeeded through the Cloudflare Worker. 1. Create a Cloudflare Worker Create a free Cloudflare account, open Workers & Pages, create a Worker, and replace its code with the following: 2. Configure the secrets In the Worker settings, under Settings → Variables and Secrets, create these two secrets: GEMINI API KEY: your existing Google AI Studio API key. RELAY TOKEN: a strong, random secret of your own. Publish the Worker and copy its URL, which should look like this: https://your worker.your subdomain.workers.dev Never put your actual API key or relay token in the Worker source code or publish them in a forum post. 3. Change your application to use the Worker Instead of sending requests directly to: https://generativelanguage.googleapis.com send them to your Worker URL. Add a request header named x relay token, using the value of RELAY TOKEN. Do not send the actual Gemini API key from your application; the Worker adds it when forwarding the request to Google. For a Java Spring Boot application, this means changing the REST client's base URL and replacing the x goog api key header with x relay token. Keep the model name, request body, and other application l…

Related discussions

Wispbyte Community Forum