Codex Cloud can't fetch deps from hex.pm (Elixir package manager)
What version of Codex is running?
Cloud
What subscription do you have?
Pro
Which model were you using?
default
What platform is your computer?
Cloud
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
Codex Cloud is unable to fetch packages from hex.pm, the Elixir package manager. The MITM proxy that's in front of the environment is having connectivity issues, making hex.pm unusable:
Elixir is a popular programming language and currently to get it working with Codex, we need to use alternative mirrors, and in my tests, the only one that sometimes works is the one hosted in China which is not idea.
I wasn’t able to find where to report feedback or bugs, so I’m writing it here. I hope the team can look into this and tweak the Codex VM environment a bit to make Codex usable for Elixir development without a huge bootstrap script.
Findings
Running mix deps.get fails immediately because Mix cannot download deps from builds.hex.pm, reporting an HTTP 503 from the upstream service through Envoy.
Even installing Hex explicitly with mix local.hex --force encounters the same 503 response, so the failure happens before any project dependencies are fetched.
Network observations
The container is configured to use a corporate HTTP(S) proxy (Envoy MITM) for all outbound traffic, as shown by the numerous *_proxy environment variables and the injected CA certificate paths.
Direct access with curl succeeds (HTTP 200), so the proxy itself can reach builds.hex.pm when acting on behalf of a typical client.
When the Erlang/OTP HTTP client (:httpc) tries to reach the same endpoint without proxy settings, the call fails with :enetunreach, showing that direct egress is blocked; the proxy must be used.
After pointing :httpc at the proxy, the request reproduces the 503 “upstream connect error … connection termination” returned by Envoy, matching Mix’s behavior. This indicates an incompatibility between the Erlang HTTP stack that Mix uses and the environment’s proxy handling for HTTPS traffic.
Conclusion
Mix relies on Erlang’s built-in :httpc, which either cannot reach hex.pm directly (egress blocked) or, when routed through the mandated Envoy proxy, receives a 503 because Envoy terminates the upstream TLS connection before headers are returned. That proxy-level failure prevents Mix from downloading Hex, explaining why mix deps.getcannot proceed without switching to an alternate mirror or otherwise adjusting the proxy configuration.
What steps can reproduce the bug?
Scaffold a new elixir project, such as with phoenix:
mix archive.install hex phx_new
mix phx.new
mix deps.get
Commit everything, setup the environment in Codex Cloud, then in the setup script use mix deps.get
Codex Cloud will be unable to fetch the dependencies from hex.pm
What is the expected behavior?
mix deps.get should just work, like in any other environment
Additional information
_No response_
6 Comments
I'd love to try codex web but it's currently unusable for Elixir projects.
I'm seeing the same SSL issues with Pkl, which means I can't set up hk for pre-commit verification.
Every run, the agent complains "
hk fixfailed in this environment due to TLS certificate validation when Pkl attempted to fetch from GitHub".Any update on fixing this?
Sad to see codex cloud so close to being really useful, but blocked by not being able to get packages.
+1
Adding more evidence from a Codex Cloud sandbox debugging session today, since this looks like a proxy ↔ Erlang
:httpcinteraction rather than a Hex/Mix bug. Other languages on the same image transit Envoy fine; only:httpc503s.Environment
Codex Cloud sandbox, mise-installed Elixir 1.18.3 / OTP 27.
The Envoy MITM CA is merged into
/etc/ssl/certs/ca-certificates.crt.curlthrough the same Envoy: all 200 OKEvery
:httpcrequest: 503Things that did not help
| Knob | Result |
|---|---|
|
HEX_UNSAFE_HTTPS=1| 503 ||
HEX_CACERTS_PATH=/etc/ssl/certs/ca-certificates.crt| 503 ||
HEX_MIRROR=https://hexpm.upyun.com| 503 ||
HEX_HTTP_CONCURRENCY=1,HEX_HTTP_TIMEOUT=120| 503 || Retries with backoff | 503 every attempt |
Switching upstream to UpYun produces the same Envoy 503, which suggests Envoy is bouncing the request before reaching any upstream — the failure is in the proxy's handling of
:httpc's connection, not at hex.pm.Why this looks proxy-side
Every other language runtime on the Codex Cloud image (Python
requests/urllib3, Nodenpm, Rubygem,cargo,go mod,apt,git/libcurl) transits the same Envoy fine. The only thing that 503s is Erlang's:httpc.:httpcis much thinner than libcurl/requests/reqwest and likely sends a CONNECT framing or TLS handshake shape (cipher list, ALPN, SNI) that the Envoy MITM rejects. A fix on the Envoy side would unblock every Elixir/Erlang user on Codex Cloud without requiring changes to Mix, Hex, or OTP — and would address the Pkl case @sargunv reported above for the same reason.Working workaround
Until this is fixed I'm pre-vendoring
deps/into the repo and using a setup script that:rebar3viacurl(libcurl works),mix archive.install github hexpm/hex branch latest(uses git/libcurl, not:httpc),HEX_OFFLINE=1and runsmix deps.compileagainst the vendored sources — nevermix deps.get.Works reliably but
deps/re-vendor on every dep bump is rough. Happy to provide raw:httpctraces or test proxy-config changes.I got it working and put my solution into a small golang proxy you can plug into your Codex: https://github.com/dvcrn/hexpm-envoy-proxy
The issue is that
httpcis sending empty headers likewhich is valid spec, but envoy is still imploding.
The golang proxy I wrote is stripping empty headers out before forwarding the requests to the envoy proxy that Codex is using. Set up the maintenance script like this:
And set the following environment variables in your Codex env:
This will tell hex to use localhost:8787 as mirror, which just strips empty headers and forwards them to the local
HTTP_PROXY(envoy)I can now natively resolve hex packages in my Codex environments