Skip to content

Instantly share code, notes, and snippets.

@junielton
Last active December 11, 2025 20:56
Show Gist options
  • Select an option

  • Save junielton/8ae25f55a3e795400666cb8d372ee678 to your computer and use it in GitHub Desktop.

Select an option

Save junielton/8ae25f55a3e795400666cb8d372ee678 to your computer and use it in GitHub Desktop.
How to Run Antigravity Browser Automation on WSL2

Strategy: Bridge the WSL connection to use the native Windows Chrome installation via port forwarding. This avoids slow rendering inside Linux and utilizes your GPU.

1. Windows Setup (One-Time)

Open PowerShell as Administrator for these steps.

  1. Get your WSL Gateway IP (Run this inside your WSL terminal):

    ip route show | grep -i default | awk '{ print $3}'

    Copy this IP (e.g., 172.25.x.x). We will refer to it as GATEWAY_IP.

  2. Configure Port Forwarding (Run in PowerShell Admin, replace GATEWAY_IP):

    netsh interface portproxy add v4tov4 listenport=9222 listenaddress=GATEWAY_IP connectport=9222 connectaddress=127.0.0.1
  3. Open Firewall (Run in PowerShell Admin):

    New-NetFirewallRule -DisplayName "Chrome Remote Debug" -Direction Inbound -LocalPort 9222 -Protocol TCP -Action Allow

2. WSL Setup & Automation

Configure Linux to automatically tunnel requests to Windows.

  1. Install socat:

    sudo apt update && sudo apt install -y socat
  2. Add Auto-Connect Script: Append this block to your ~/.bashrc (or ~/.zshrc) file to ensure the tunnel starts every time you open the terminal:

    # --- Antigravity / Chrome Bridge Setup ---
    # 1. Get Windows Gateway IP dynamically
    WIN_IP=$(ip route show | grep -i default | awk '{ print $3}')
    
    # 2. Start socat in background if not already running
    if ! pgrep -f "socat TCP-LISTEN:9222" > /dev/null; then
        socat TCP-LISTEN:9222,fork,reuseaddr TCP:$WIN_IP:9222 &> /dev/null &
    fi
  3. Apply changes:

    source ~/.bashrc

3. Antigravity IDE Configuration

Go to Antigravity Settings -> Browser Subagent.

  • Chrome Binary Path: (Use the path to your Windows Chrome executable via the /mnt mount) /mnt/c/Program Files/Google/Chrome/Application/chrome.exe

  • Browser CDP Port: 9222


Troubleshooting

If automation stops working after a full PC restart, the WSL IP address might have changed.

  1. Get the new IP in WSL:
    ip route show | grep -i default | awk '{ print $3}'
  2. Update the Windows Rule (PowerShell Admin):
    netsh interface portproxy set v4tov4 listenport=9222 listenaddress=NEW_IP connectport=9222 connectaddress=127.0.0.1
@greg-mcnamara-datacom
Copy link

Hi @sharjeelsohail @smith-espenrydningen I'm not sure if it's fully working yet, but it looks like the problem was the Chrome profile. I believe Antigravity is supposed to create a new profile for the extension to be installed in, but it was trying to install in my default profile and failing. When I created a new profile and switched to it when Antigravity launched the browser, I was able to install the extension. I changed the path to the Antigravity Chrome profile in Antigravity settings to the Chrome for Windows profile folder for the new one I created e.g. /mnt/c/Users/[username]/AppData/Local/Google/Chrome/User Data/Profile 1 and now when I launch from Antigravity it does open a new Chrome window in that profile, but it defaults to the onboarding page asking to install the extension (already installed). I'll keep you posted on progress!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment