Operations 8 min read

One-Command Proxy Setup for VS Code to Unlock Google Gemini

This guide explains why VS Code needs a proxy for Google Gemini, then shows safe one‑line commands for macOS/Linux (using jq) and Windows (PowerShell) to edit settings.json, verify the change, and handle common SSL or GUI alternatives.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
One-Command Proxy Setup for VS Code to Unlock Google Gemini

Developers often need a reliable network proxy for VS Code extensions like Google Gemini, which require direct access to external services. Configuring the proxy manually via the GUI can be tedious, so a command‑line approach that directly edits settings.json is both faster and reproducible.

Core Idea: Edit settings.json Directly

VS Code stores all user settings, including proxy information, in a JSON file named settings.json. By safely inserting the http.proxy field, the editor and its extensions will route traffic through the specified proxy.

Unsafe Quick Append (Warning)

Appending raw JSON with >> or PowerShell Add-Content can corrupt the file if it lacks a trailing comma or is empty. This may render VS Code unable to read its configuration.

Safer Method for macOS/Linux (using jq )

Install jq if needed ( brew install jq or sudo apt-get install jq). The following script ensures the file exists as a valid JSON object, then merges the proxy setting:

# Define file path and proxy address
SETTINGS_FILE="$HOME/.config/Code/User/settings.json"
PROXY_URL="http://127.0.0.1:7890"

# Ensure the file exists and contains an empty JSON object if missing or empty
if [ ! -f "$SETTINGS_FILE" ] || [ ! -s "$SETTINGS_FILE" ]; then
    echo "{}" > "$SETTINGS_FILE"
fi

# Safely add or update http.proxy using jq
jq --arg proxy_url "$PROXY_URL" '. + {"http.proxy": $proxy_url}' "$SETTINGS_FILE" > tmp.$$.json && mv tmp.$$.json "$SETTINGS_FILE"

macOS users note: The settings file may also reside at $HOME/Library/Application Support/Code/User/settings.json.

PowerShell Solution for Windows

PowerShell’s native JSON handling avoids structural damage. Replace the placeholder URL with your own proxy address.

# Define file path and proxy address
$settingsFile = "$env:APPDATA\Code\User\settings.json"
$proxyUrl = "http://127.0.0.1:7890" # replace with your proxy

# Ensure the file exists and is a valid JSON object
if (-not (Test-Path $settingsFile) -or -not (Get-Content $settingsFile -Raw).Trim()) {
    '{}' | Set-Content -Path $settingsFile
}

# Read, modify, and write back safely
$config = Get-Content $settingsFile -Raw | ConvertFrom-Json
$config | Add-Member -MemberType NoteProperty -Name 'http.proxy' -Value $proxyUrl -Force
$config | ConvertTo-Json -Depth 100 | Set-Content -Path $settingsFile

Verification and Activation

Open settings.json in VS Code: Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS), type “Open User Settings (JSON)”, and hit Enter.

Check the entry: Ensure a line like "http.proxy": "http://127.0.0.1:7890" appears.

Restart VS Code: The proxy takes effect after a restart, enabling Google Gemini and other extensions to connect.

Additional Tips

SSL certificate issues: If the proxy uses custom certificates, you may need to set http.proxyStrictSSL to false, though keeping it true is safer.

GUI alternative: Open Settings (Ctrl+,), search for “Proxy”, and fill the “Http: Proxy” field; VS Code will update settings.json automatically.

Partial traffic routing: For selective proxying, more advanced networking tools are required, but a global proxy suffices for most extensions.

Conclusion

With a single command (or a short PowerShell script), you can reliably configure a proxy for VS Code, eliminating connectivity problems for AI assistants like Google Gemini. This method is quick, script‑friendly, and suitable for automating new development environment setups.

proxyCommand LinejqVS CodePowerShellGoogle Geminisettings.json
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.