Deploy Phoenix to a VPS: mix release and Postgres
Deploy an Elixir Phoenix app to your own VPS: ox builds a mix release with its assets, runs Release.migrate, starts it under systemd, and adds PostgreSQL.
Last updated 2026-10-09
On this page
To deploy Phoenix to a VPS with ox, add the repo as a project and deploy it, with no Dockerfile and no ox.toml. ox reads mix.exs, lib/hello/release.ex and .tool-versions, runs mix local.hex --force && mix local.rebar --force && MIX_ENV=prod mix deps.get --only prod, mix compile, mix assets.deploy, mix release and _build/prod/rel/hello/bin/hello eval 'Hello.Release.migrate()' for the migrations, then starts _build/prod/rel/hello/bin/hello start under systemd behind Caddy with HTTPS, and sets up postgres 18 for it. Run ox check in your repo to see the same plan before the first deploy.
Tested on a real server. A Phoenix app deployed and served on a real Ubuntu server in ox's test lab, and the plan below is what ox check prints for a minimal one.
mix.exs, lib/hello/release.ex and .tool-versions, builds the plan on the card, and starts _build/prod/rel/hello/bin/hello start on your server. The cylinders are the services the repo asked for.What ox detects in a Phoenix repo
This is the plan ox check prints for a minimal an Elixir Phoenix app, with no ox.toml. Each row says where its value came from: a file in the repo, or ox's default.
| Field | Value | Source |
|---|---|---|
app.start | PHX_SERVER=true RELEASE_TMP=/tmp RELEASE_DISTRIBUTION=none PHX_HOST=$PUBLIC_HOST _build/prod/rel/hello/bin/hello start | detected:mix.exs |
build.install | mix local.hex --force && mix local.rebar --force && MIX_ENV=prod mix deps.get --only prod | detected:mix.exs |
build.commands[0] | MIX_ENV=prod mix compile | detected:mix.exs |
build.commands[1] | MIX_ENV=prod mix assets.deploy | detected:mix.exs |
build.commands[2] | MIX_ENV=prod mix release | detected:mix.exs |
build.migrate | RELEASE_TMP=/tmp _build/prod/rel/hello/bin/hello eval 'Hello.Release.migrate()' | detected:lib/hello/release.ex |
tools.elixir | 1.18.4-otp-27 | detected:.tool-versions |
packages | erlang-dev | tools.elixir |
packages | erlang-nox | tools.elixir |
services.postgres | postgres 18 (shared) | detected:mix.exs |
ox check also prints these hints for it:
not installed: erlang (from .tool-versions): it is never a mise tool in ox: mise compiles Erlang/OTP from source on the server, and that fails there. Every app with Elixir gets Ubuntu's Erlang/OTP 27 from ox (packages = ["erlang-nox"] for one without)
The ox.toml for Phoenix
None is needed: the plan above comes from the repo alone. Write one to serve your own domain or to change what ox detected. This one passes ox check against the same repo: [app] keeps the detected start command and build. Once a repo has an ox.toml, ox adds no service itself, so list each one under [services].
domains = ["www.example.com"]
[app]
[services]
postgres = {}Check and deploy Phoenix
Add the repo as a project, then check and ship it from a terminal:
ox check # in the repo: the plan above, offline
ox new <owner/repo> --server <server> # add the repo as a project
ox deploy <project> --wait # stream the deploy, exit with its result
ox logs <project> --follow # the app's own logsVariables to set for Phoenix
Set SECRET_KEY_BASE (Rails or Phoenix key base: 128 hex characters and Generate makes it) before the first deploy: ox check asks for it, and the deploy stops until it has a value. Use the dashboard's Variables tab or ox vars set <project> KEY, which asks for the value.
ox provides these to the app itself: PORT, HOST, OX_ENV, OX_PROJECT, OX_RELEASE, OX_DATA_DIR, PUBLIC_URL, PUBLIC_HOST, PUBLIC_SCHEME, PUBLIC_PORT and DATABASE_URL.
If the Phoenix deploy fails
set these before deploying: SECRET_KEY_BASE (Rails or Phoenix key base: 128 hex characters, Generate makes it): A variable the app needs has no value. Set it on the dashboard's Variables tab, or withox vars set <project> KEY. More.config/runtime.exs does not read PORT: set the endpoint's http port to String.to_integer(System.get_env("PORT")), as mix phx.new does: Read the port fromPORTinconfig/runtime.exs, as a new Phoenix app does. More.no Release.migrate in lib/, so ox runs no migrations: run mix phx.gen.release to add one: Runmix phx.gen.releaseonce and commit the module it writes. More.
Visitors never see a failed deploy: the old release serves until the new one is healthy.
Next steps
- Set variables and secrets on the dashboard or with
ox vars. - The
[app]keys: start, health check, memory and the rest. - Service dashboards: your database's status, size, backups and data.
- Add a custom domain; Caddy gets its certificate.
- Read the logs live, search them, or download them.
- Set variables and secrets on the dashboard or with
ox vars.
Phoenix FAQ
Do I need a Dockerfile or an ox.toml to deploy Phoenix to a VPS?
No. ox does not use Docker, and ox check on a Phoenix repo with no ox.toml prints Ready to deploy. Write an ox.toml only to change what ox detected.
What does ox install on the server for Phoenix?
Only what the plan names: elixir 1.18.4-otp-27 (read from .tool-versions) and the apt packages erlang-dev and erlang-nox. Your app's own dependencies are installed by the build into the release folder, not system-wide.
Which Erlang and Elixir does ox install?
Erlang/OTP 27 from Ubuntu's archive, and the build for OTP 27 of the Elixir your .tool-versions names, as the plan above shows (1.18, or one mix.exs allows, without it). An Elixir older than 1.17 does not run on OTP 27, and ox installs no other Erlang.
Related guides
- Spring Boot (Maven)Deploy a Spring Boot app built with Maven to your own VPS: ox builds the jar with mvnw, installs Java 21, runs it under systemd and adds PostgreSQL for it.
- Spring Boot (Gradle)Deploy a Spring Boot app built with Gradle to your own VPS: ox runs gradlew bootJar, reads the Java version from build.gradle.kts, and runs the jar.
The Stacks page lists every stack, and the ones ox does not deploy yet.
New to running your own server? How ox self-hosts your apps gives the overview, and the blog's deploy guides walk through a setup by hand.