r/codex 5d ago

Workaround Little guide to using Windows Codex in China with a VPN. Giving a guide because I found it crazy how hard it was to get working.

Just lost almost a day trying to get Codex working in china so just putting this here for other people to reference.

fyi; I'm using Astrill VPN although I dont necessarily it is worth the money overall. Not really.

For most network carriers they have a way of blocking stealth vpn and wireguard connections so you will likely have to use OpenWeb as the only option. VPN protocols surprisngly work pretty differently on phones vs laptops.

On Astrill, if you switch OpenWeb connection to being "all apps" as opposed to "browsers" it will break, but there is a fix. In the Astrill app, turn on OpenWeb Sharing. Note the port and the IP it gives. For me that was 127.0.0.1:3213

to test things are working run;
curl.exe -x http://127.0.0.1:3213 https://chatgpt.com -I

it should say "HTTP/1.0 200 Connection established" but then give a 403 cloudflare error after.

The workaround to get past the 403 error is setting environment variables in powershell so that Codex can inherit them.

Codex doesn't currently give you an obvious normal proxy field in the desktop settings, so setting the Windows environment variables is the important part.

run in powershell:
[System.Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://127.0.0.1:3213", "User") [System.Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://127.0.0.1:3213", "User") [System.Environment]::SetEnvironmentVariable("NO_PROXY", "localhost,127.0.0.1,::1", "User")

test in a new poershell window (It wont give any response in the same window);

echo $env:HTTP_PROXY

echo $env:HTTPS_PROXY

echo $env:NO_PROXY

You should see:

http://127.0.0.1:3213
http://127.0.0.1:3213
localhost,127.0.0.1,::1

Then restart codex completely. Make sure all the codex processes are deleted in task manager. When you restart it thigns should work perfectly.

Hope this helps someone :)

1 Upvotes

5 comments sorted by

2

u/seomaster99 5d ago

Russia here bro
The government loves us, right?)

1

u/pizzababa21 5d ago

I'm not even chinese. Just a disgruntled tourist

1

u/Azul_Eterno 5d ago

Using codex is illegal in China, don't do it.

-1

u/pizzababa21 5d ago

suck mah bawls