Codex sandbox blocks DNS/SSH sockets; git push fails with "Could not resolve hostname github.com"
What version of Codex CLI is running?
codex-cli 0.104.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.2-codex
What platform is your computer?
Linux 6.18.9-arch1-2 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
Alacritty
What issue are you seeing?
Inside Codex sandbox, outbound networking and socket creation appear blocked.
Git operations to GitHub fail before authentication due to DNS failures.
Command:
git push origin --delete <REDACTED_BRANCH>
Output:
ssh: Could not resolve hostname github.com: Temporary failure in name resolution
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
DNS / network checks in sandbox:
getent hosts github.com && ssh -T git@github.com
<no output>
nslookup github.com || true; ping -c 1 github.com || true
net.c:136:try_proto(): socket(): Operation not permitted (1)
net.c:136:try_proto(): socket(): Operation not permitted (1)
(null): can't find either v4 or v6 networking
ping: socktype: SOCK_DGRAM
ping: socket: Operation not permitted
SSH agent:
ssh-add -l
Error connecting to agent: Operation not permitted
ssh-agent -s
Couldn't prepare agent socket
Operation not permitted
What steps can reproduce the bug?
1) Start Codex CLI in any git repo that has an SSH remote (git@github.com:...).
2) Run:
getent hosts github.com
git push --dry-run
3) Observe DNS/socket failures (Operation not permitted) and git push failure.
What is the expected behavior?
git push should proceed to authentication or fail with a normal SSH auth error,
not fail due to DNS/socket restrictions inside the Codex environment.
Additional information
- This is NOT the “Bad owner or permissions on /etc/ssh/ssh_config.d” issue.
In this environment, /etc/ssh and ssh_config.d are owned by root and
ssh -G github.com parses cleanly.
- The failure appears to be sandbox socket/network restrictions.
- When elevated execution was explicitly approved, git push/delete succeeded.
- /etc/resolv.conf contains a nameserver entry, but DNS lookups still fail in
sandbox.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Hi @etraut-openai ,
Update: Network Issue Resolved (Not a Codex Bug)
After deeper testing, the earlier
git pushfailure (Could not resolve hostname github.com) was not a Codex CLI defect.Root cause: network access was disabled in the sandbox configuration.
Initial symptoms:
socket(): Operation not permittedAfter enabling:
Minimal validation confirmed:
git push --dry-runsucceedsConclusion: behavior was consistent with sandbox policy (network disabled by default), not a bug in Codex CLI.
Lesson learned: perform layered validation (socket → raw TCP → DNS → transport) before reporting a defect.
Thank you for the time taken to review and investigate this.
Apologies — my previous comment asked you to provide reproduction steps when you had already included extremely detailed ones. That was unhelpful. Here's the actual analysis:
What's happening: Codex CLI runs agent tasks inside a sandboxed environment that restricts system calls — including
socket(). This is intentional: the sandbox blocks outbound network access by default to prevent unintended side effects.The specific mechanism varies by platform:
sandbox-exec) for similar restrictionsEither way, the result is the same:
socket(): Operation not permittedwhen anything tries to make a network call, including DNS resolution (UDP socket) and SSH (TCP socket).Why
git pushworked when you explicitly approved elevated execution: That's the intended flow — Codex temporarily lifts sandbox restrictions for that specific command when you approve it. That approval is the user's consent gate for network operations.The correct workflow for git operations in Codex:
git push, approve the elevated/network operation when promptedgit pushyourself outside the Codex session after reviewing the changesThis is by design, not a bug — but your feedback is valid: the error message could be clearer. Instead of a raw
socket(): Operation not permitted, it should say something like "Network access blocked by sandbox — approve this operation to continue." That would be a good UX improvement to request.The root issue (confusing error messages + unclear approval flow for network ops) is worth filing as a separate feature request for better sandbox UX.
Hope this helps\! 🦞
@sstklen Thanks for replying back, and no worries regarding the missed details, the important is that both have learn something from this. I'm new on the task to contribute publicly and I will try my best to do it better.
For future readers, if you have started your session with
and included prompts to
git pushoraws cloudwatch ...and running into DNS Issues in the sandbox, try ctrl-c and create a new session with slightly lower permission level:You may be thinking it would be convenient to give Codex a list of commands it's allowed to do without asking. That has been discussed a lot in 3085 and let me save you sifting through the comments to find the Rules mechanism so you can customize it.
This fixed it! Thank you