[API Error: exception TypeError: fetch failed sending request]
What happened?
│ Debug Console (ctrl+o to close) │ │ │ │ ... first 163 lines hidden ... │ │ address: '216.239.32.223', │ │ port: 443 │ │ }, │ │ Error: connect ETIMEDOUT 216.239.36.223:443 │ │ at createConnectionError (node:net:1652:14) │ │ at afterConnectMultiple (node:net:1682:16) { │ │ errno: -110, │ │ code: 'ETIMEDOUT', │ │ syscall: 'connect', │ │ address: '216.239.36.223', │ │ port: 443 │ │ } │ │ ] │ │ }
What did you expect to happen?
Fix it
Client information
About Gemini CLI │ │ │ │ CLI Version 0.1.9 │ │ Git Commit 8adc586 │ │ Model gemini-2.5-pro │ │ Sandbox gemini-cli-sandbox │ │ OS linux │ │ Auth Method gemini-api-key
Login information
API key
Anything else we need to know?
No response
Looks like network issue. Can you give more context about this ? how to reproduce ?
I logged in and had the first conversation, and then it prompted "✕ [API Error: exception TypeError: fetch failed sending request]"
[Windows 11] [nodejs 20.19.3] [Login method: APIKey]
I am having the same issue.
│ Debug Console (ctrl+o to close) │ │ │ │ ℹ Authenticated via "gemini-api-key". │ │ ✖ Error flushing log events: AggregateError [ETIMEDOUT]: │ │ at internalConnectMultiple (node:net:1134:18) │ │ at afterConnectMultiple (node:net:1715:7) { │ │ code: 'ETIMEDOUT', │ │ [errors]: [ │ │ Error: connect ETIMEDOUT 216.239.34.223:443 │ │ at createConnectionError (node:net:1678:14) │ │ at Timeout.internalConnectMultipleTimeout (node:net:1737:38) │ │ at listOnTimeout (node:internal/timers:610:11) │ │ at process.processTimers (node:internal/timers:543:7) { │ │ errno: -60, │ │ code: 'ETIMEDOUT', │ │ syscall: 'connect', │ │ address: '216.239.34.223', │ │ port: 443 │ │ }, │ │ Error: connect ETIMEDOUT 216.239.32.223:443 │ │ at createConnectionError (node:net:1678:14) │ │ at Timeout.internalConnectMultipleTimeout (node:net:1737:38) │ │ at listOnTimeout (node:internal/timers:610:11) │ │ at process.processTimers (node:internal/timers:543:7) { │ │ errno: -60, │ │ code: 'ETIMEDOUT', │ │ syscall: 'connect', │ │ address: '216.239.32.223', │ │ port: 443 │ │ }, │ │ Error: connect ETIMEDOUT 216.239.38.223:443 │ │ at createConnectionError (node:net:1678:14) │ │ at Timeout.internalConnectMultipleTimeout (node:net:1737:38) │ │ at listOnTimeout (node:internal/timers:610:11) │ │ at process.processTimers (node:internal/timers:543:7) { │ │ errno: -60, │ │ code: 'ETIMEDOUT', │ │ syscall: 'connect', │ │ address: '216.239.38.223', │ │ port: 443 │ │ }, │ │ Error: connect ETIMEDOUT 216.239.36.223:443 │ │ at createConnectionError (node:net:1678:14) │ │ at afterConnectMultiple (node:net:1708:16) { │ │ errno: -60, │ │ code: 'ETIMEDOUT', │ │ syscall: 'connect', │ │ address: '216.239.36.223', │ │ port: 443 │ │ } │ │ ] │ │ } │
is this persisting issue for all of you? are you behind a network where google services might be blocked? (country level, school, firewall ....). What is the output of this:
ping 216.239.36.223
Environment variables set https_proxy and http_proxy to solve network problems, but new problems have arisen: ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Debug Console (ctrl+o to close) │ │ │ │ ⚠ Warning: Could not read directory /root: EACCES: permission denied, scandir '/root' │ │ ℹ Authenticated via "gemini-api-key". │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯
in which folder you are currently at? And what is your prompt? @King-skrs
It worked, I used docker exec -u root -it [your container ID or name] /bin/bash
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: process.env.GEMINI_API_KEY,
apiVersion: "v1alpha",
});
const config = {
responseMimeType: "text/plain",
temperature: 0.1,
};
const model = "gemini-2.5-flash";
const contents = [
{
role: "user",
parts: [
{
text: hi,
},
],
},
];
async function main() { const response = await ai.models.generateContent({ model, config, contents, }); console.log(response.text); }
main();
Hi all, I'm trying to run this code but it gives me error as below
mcp-server-main/node_modules/@google/genai/dist/node/index.mjs:13059
throw new Error(exception ${e} sending request);
^
Error: exception TypeError: fetch failed sending request at mcp-server-main/node_modules/@google/genai/dist/node/index.mjs:13059:19 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Models.generateContent (mcp-server-main/node_modules/@google/genai/dist/node/index.mjs:14220:24) at async main (mcp-server-main/client.js:31:20)
Node.js v22.17.0 Please help me to fix this issue
Same after upgrade to 0.1.14
Found possible duplicate issues:
- #1549: (#0.9376657009124756)
- #4487: (#0.9045245320953293)
Hello. I also encountered the same problem, but I was able to solve it, so I'd like to share the details.
Specs
Windows 11 WSL2 Ubuntu 22.04.3 LTS gemini-cli 0.1.18
Cause
The PROXY_HTTP environment variable was set, and gemini-cli was trying to access via PROXY_HTTP.
Solution
unset HTTP_PROXY
unset http_proxy
I'm using windows11, powershell and connect to network by proxy. I solve it by set the proxy enviroment. first close gemini cli, then set proxy, then start gemini
set the proxy
$env:http_proxy = "http://xxx.xxx.xxx.xxx:8080" $env:https_proxy = "http://xxx.xxx.xxx.xxx:8080"
unset the proxy $env:http_proxy = $null $env:https_proxy = $null
I'm using windows11, powershell and connect to network by proxy. I solve it by set the proxy enviroment. first close gemini cli, then set proxy, then start gemini
set the proxy
$env:http_proxy = "http://xxx.xxx.xxx.xxx:8080" $env:https_proxy = "http://xxx.xxx.xxx.xxx:8080"
unset the proxy $env:http_proxy = $null $env:https_proxy = $null
I am having the same issue.
Can use the ~/.gemini/.env file to persist variables, Seepersisting-environment-variables.
This solved my problem, the file content is as follows:
GEMINI_API_KEY="API-KEY"
HTTP_PROXY="http://xxx.xxx.xxx.xxx:8080/"
http_proxy="http://xxx.xxx.xxx.xxx:8080/"
HTTPS_PROXY="http://xxx.xxx.xxx.xxx:8080/"
https_proxy="http://xxx.xxx.xxx.xxx:8080/"
Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.
It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.
Thank you for your contribution!
On Windows 10, I used the approach provided by @yangjianlin-c and worked. But set it in Gemini env file as mentioned by @AzureZee did not work.