Gemini CLI Not Responding

Troubleshoot and fix issues when Gemini CLI hangs, freezes, or becomes unresponsive.

Quick Fixes

1. Force quit and restart:

# Kill hanging process

pkill -f gemini

killall gemini-cli

# Or use Ctrl+C if still in terminal

^C

2. Check system resources:

# Check CPU and memory usage

top -p $(pgrep gemini)

htop # if available

# Check disk space

df -h

3. Test with simple command:

gemini --version

gemini "Hello, world!"

Common Causes and Solutions

❌ Network Timeout

Symptoms: CLI hangs during API calls, no response for extended periods

Solutions:

1. Check internet connection:

ping google.com

curl -I https://generativelanguage.googleapis.com

2. Increase timeout:

gemini --timeout 60000 "your prompt"

gemini config set timeout 60000

3. Configure proxy if needed:

export HTTP_PROXY=http://proxy.company.com:8080

export HTTPS_PROXY=http://proxy.company.com:8080

❌ Memory Issues

Symptoms: System becomes slow, CLI freezes with large files or complex requests

Solutions:

1. Check memory usage:

free -h # Linux

vm_stat # macOS

wmic OS get TotalVisibleMemorySize,FreePhysicalMemory # Windows

2. Reduce request size:

gemini --max-tokens 1000 "shorter prompt"

gemini --chunk-size 1MB large-file.txt

3. Close other applications:

Free up system memory by closing unnecessary applications

❌ API Rate Limiting

Symptoms: CLI hangs after several requests, especially in batch operations

Solutions:

1. Add delays between requests:

gemini --rate-limit 60 "request 1"

sleep 1 && gemini "request 2"

2. Use batch mode with throttling:

gemini batch --throttle 1s "*.js" "process files"

❌ Configuration Issues

Symptoms: CLI starts but hangs on first command, inconsistent behavior

Solutions:

1. Validate configuration:

gemini config validate

gemini config show

2. Reset to defaults:

gemini config reset

# Or manually delete config file

rm ~/.config/gemini-cli/config.json

3. Test with minimal config:

gemini --no-config --api-key YOUR_KEY "test"

Diagnostic Commands

System diagnostics:

# Check system resources

gemini diagnostics --system

# Check network connectivity

gemini diagnostics --network

# Check configuration

gemini diagnostics --config

Debug mode:

gemini --debug --verbose "test command"

gemini --trace "test command"

Log analysis:

# View recent logs

gemini logs --tail 50

gemini logs --level error

# Clear logs

gemini logs --clear

Process Management

Finding Hanging Processes

# Find Gemini CLI processes

ps aux | grep gemini

pgrep -fl gemini

# Check process tree

pstree -p $(pgrep gemini)

# Monitor process activity

strace -p $(pgrep gemini) # Linux

dtruss -p $(pgrep gemini) # macOS

Graceful Termination

# Send SIGTERM (graceful)

kill $(pgrep gemini)

# Send SIGKILL (force)

kill -9 $(pgrep gemini)

# Kill all related processes

pkill -f "gemini.*"

Timeout Management

# Set command timeout

timeout 30s gemini "long running command"

# Kill after specific time

timeout --kill-after=5s 30s gemini "command"

# Use with retry

timeout 30s gemini "command" || echo "Command timed out"

Prevention Strategies

Resource Monitoring

Set up monitoring:

gemini config set monitoring.enabled true

gemini config set monitoring.memoryLimit "2GB"

gemini config set monitoring.timeoutWarning 30000

Use resource limits:

ulimit -m 2097152 # 2GB memory limit

ulimit -t 300 # 5 minute CPU time limit

Safe Operation Practices

  • • Test commands with small inputs first
  • • Use timeouts for potentially long-running operations
  • • Monitor system resources before large operations
  • • Use batch operations with appropriate throttling
  • • Keep the CLI updated to the latest version

Configuration Best Practices

{ "timeout": 30000, "maxTokens": 2048, "retryAttempts": 3, "retryDelay": 1000, "monitoring": { "enabled": true, "memoryWarning": "1GB", "timeoutWarning": 25000 } }

Recovery Steps

Complete recovery procedure:

# 1. Stop all processes

pkill -f gemini

# 2. Clear temporary files

rm -rf ~/.cache/gemini-cli/*

rm -rf /tmp/gemini-*

# 3. Reset configuration

gemini config reset

# 4. Test basic functionality

gemini --version

gemini "Hello, world!"

If problems persist:

# Reinstall Gemini CLI

npm uninstall -g @google/gemini-cli

npm install -g @google/gemini-cli

# Clear npm cache

npm cache clean --force

Getting Help

Collect diagnostic information:

gemini diagnostics --full > diagnostics.txt

gemini logs --export logs.txt

gemini config show > config.txt

System information:

uname -a # System info

node --version # Node.js version

npm --version # npm version

gemini --version # CLI version

Next Steps

If you're still experiencing issues, try these resources: