---
title: "Deploy Codex"
description: "OpenAI Codex CLI box: browser terminal + SSH, git, gh, Node, home persists"
category: "AI/ML"
url: https://railway.com/deploy/codex-cli
---

# Deploy Codex

OpenAI Codex CLI box: browser terminal + SSH, git, gh, Node, home persists

**[Deploy Codex on Railway](https://railway.com/template/codex-cli)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/codex-cli/manifest.json

- **Creator:** Two Workspaces
- **Category:** AI/ML

## Template content

### codex https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@latest/dark/openai.png

- **Image:** ghcr.io/two-workspaces/codex:23f81a5
- **Health check:** /healthcheck
- **Public domain:** Yes

## Documentation

# Deploy and Host a Codex Cloud Box on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/new/template/codex-cli?referralCode=sLjDXb&utm_medium=integration&utm_source=button&utm_campaign=codex)

This template gives you an always-on Ubuntu 24.04 workstation with the [OpenAI Codex CLI](https://github.com/openai/codex) pre-installed. Open your Railway domain for a terminal in the browser, or SSH in through Railway's TCP proxy. Your home directory lives on a volume, so repos, your Codex login, GitHub auth and dotfiles survive every redeploy.

## About Hosting a Codex Cloud Box

One service, one volume. The image ships `codex`, `git`, `gh`, Node 22, Python 3 + `uv`, `tmux`, `ripgrep`, `jq`, `vim`, build tools and an OpenSSH server. A `ttyd` web terminal (basic-auth gated) and `sshd` (password or key) both drop you into the same `tmux` session, so you can start a long Codex run from your laptop and pick it up from your phone. SSH host keys are stored on the volume, so your client never sees a "host key changed" warning after a redeploy.

## Common Use Cases

- Run Codex 24/7 on a task without keeping your laptop open
- Code from an iPad, Chromebook or phone: the browser terminal needs no SSH client
- Use your ChatGPT Plus, Pro or Business plan from a box that is always on
- Keep a persistent workspace for side projects that is reachable from anywhere

## Dependencies for Codex Cloud Box Hosting

- None. Single service, no database.

### Deployment Dependencies

- [Codex CLI](https://github.com/openai/codex) and [its docs](https://developers.openai.com/codex)
- [ttyd](https://github.com/tsl0922/ttyd) web terminal
- [GitHub CLI](https://cli.github.com/)

### Implementation Details

**First use:** open your Railway domain and log in with `WEB_USER` and the generated `WEB_PASSWORD` (service Variables tab). Then sign Codex in, one of two ways:

- **ChatGPT plan:** run `codex login --device-auth`. It prints a URL and a one-time code: open the URL on any device, sign in to ChatGPT and enter the code. The login is saved under `~/.codex` on the volume.
- **API key:** set `OPENAI_API_KEY` as a service variable. The box saves it as Codex's login on every boot, so a changed key takes effect after a redeploy.

Then `cd ~/src`, clone a repo and run `codex`.

**SSH:** Railway creates a TCP proxy for port 22 on deploy. Copy the host and port from Settings → Networking and run `ssh root@‹host› -p ‹port›` with `ROOT_PASSWORD`, or add your public key to `AUTHORIZED_KEYS` and clear `ROOT_PASSWORD` for key-only login.

**Handy commands inside the box:**

- `cx` starts Codex inside a detachable `tmux` session named `codex`; `tmux attach -t codex` resumes it
- `gh auth login` or set `GH_TOKEN` to push to GitHub
- `codex doctor` checks the install, config, login and sandbox

Notes and limits:

- You are root. Anything you install outside `/root` disappears on redeploy; anything under `/root` stays. New Codex versions arrive as template updates.
- 0.5 GB of RAM runs Codex itself; give the service 1 GB or more if Codex builds Node or Python projects.
- Codex's own command sandbox (bubblewrap) cannot start in Railway's container, so the box writes `sandbox_mode = "danger-full-access"` to `~/.codex/config.toml` on first boot: Codex runs commands directly, and the container is the boundary. Edit that file to change it; it is never overwritten.
- There is no Docker daemon inside the box.
- The web terminal password is the whole security model for a root shell. Keep it strong and do not share the URL.

## Why Deploy a Codex Cloud Box on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying a Codex cloud box on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/codex-cli
