From b3cb973fef7d9c41ff9381d67ca1a4aeb9c20be1 Mon Sep 17 00:00:00 2001 From: Alex Leventer Date: Sun, 22 Nov 2026 11:41:55 -0800 Subject: [PATCH 1/2] Use Managed Postgres in the Phoenix getting started guide The guide told readers to pick Fly Postgres and showed an unmanaged postgres-flex cluster being created. It now runs fly launch --db=mpg and trims the sample output. --- elixir/getting-started/index.mdx | 116 +++---------------------------- 1 file changed, 10 insertions(+), 106 deletions(-) diff --git a/elixir/getting-started/index.mdx b/elixir/getting-started/index.mdx index e50daec719..2ede1303ec 100644 --- a/elixir/getting-started/index.mdx +++ b/elixir/getting-started/index.mdx @@ -41,126 +41,30 @@ The output ends with instructions for configuring the database and starting the When you run `fly launch` from the newly-created project directory, the launcher provides some defaults for your new app, and gives you the option to tweak the settings. -Run: +Run `fly launch` with `--db=mpg` to give the app a [Managed Postgres](/postgres) cluster: ```sh cd hello_elixir -fly launch +fly launch --db=mpg ``` -You'll get a summary of the defaults chosen for your app: +You'll get a summary of the defaults chosen for your app, including a Managed Postgres cluster on the Basic plan, and the launcher asks whether you want to tweak these settings. Type `y` to open the Fly Launch page and change the app name or region, or `n` to accept the defaults. -```output -Organization: MyOrgName (fly launch defaults to the personal org) -Name: hello_elixir (derived from your directory name) -Region: Secaucus, NJ (US) (this is the fastest region for you) -App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM) -Postgres: (not requested) -Redis: (not requested) - -? Do you want to tweak these settings before proceeding? Yes -Opening https://fly.io/cli/launch/bea626e2d179a083a3ba622a367e24ec ... -``` - -Type `y` at the prompt to open the Fly Launch page, and make the following changes to your app config: - -* Change the default app name and region, if needed. -* For Databases, select Fly Postgres, give the Postgres database app a name (for example, your app name with `-db` appended) and choose a configuration. - -Once you confirm your settings, you can return to the terminal, where the launcher will: +Once you confirm your settings, the launcher will: +* Create the Managed Postgres cluster, wait for it to be ready, and set the `DATABASE_URL` secret on your app * Run the deployment setup task * Build the image * Set secrets required by (`SECRET_KEY_BASE`, for example) * Deploy the application in your selected region -```output -Waiting for launch data... Done -Created app 'hello_elixir' in organization 'personal' -Admin URL: https://fly.io/apps/hello_elixir -Hostname: hello_elixir.fly.dev -Set secrets on hello_elixir: SECRET_KEY_BASE -Creating postgres cluster in organization personal -Creating app... -Setting secrets on app hello_elixir-db... -Provisioning 1 of 1 machines with image flyio/postgres-flex:15.3@sha256:44b698752cf113110f2fa72443d7fe452b48228aafbb0d93045ef1e3282360a6 -Waiting for machine to start... -Machine 2865550c7e96d8 is created -==> Monitoring health checks - Waiting for 2865550c7e96d8 to become healthy (started, 3/3) - -Postgres cluster hello_elixir-db created - Username: postgres - Password: EChe3BrhCjsPQEI - Hostname: hello_elixir-db.internal - Flycast: fdaa:2:45b:0:1::1d - Proxy port: 5432 - Postgres port: 5433 - Connection string: postgres://postgres:EChe3BrhCjsPQEI@hello_elixir-db.flycast:5432 - -Save your credentials in a secure place -- you won't be able to see them again! - -Connect to postgres -Any app within the MyOrgName organization can connect to this Postgres using the above connection string - -Now that you've set up Postgres, here's what you need to understand: https://fly.io/docs/postgres/getting-started/what-you-should-know/ -Checking for existing attachments -Registering attachment -Creating database -Creating user - -Postgres cluster hello_elixir-db is now attached to hello_elixir -The following secret was added to hello_elixir: - DATABASE_URL=postgres://aa_hello_elixir2:Er6pLzUBuhKcbBl@hello_elixir-db.flycast:5432/aa_hello_elixir2?sslmode=disable -Postgres cluster hello_elixir-db is now attached to hello_elixir -Generating rel/env.sh.eex for distributed Elixir support -Preparing system for Elixir builds -Installing application dependencies -Running Docker release generator -Wrote config file fly.toml -Validating /Users/anderson/test-elixir-gs/hello_elixir2/fly.toml -✓ Configuration is valid -==> Building image -Remote builder fly-builder-black-pine-7645 ready -Remote builder fly-builder-black-pine-7645 ready -==> Building image with Docker ---> docker host: 20.10.12 linux x86_64 +The output ends with the URL of your deployed app: +```output ... - ---> Pushing image done -image: registry.fly.io/hello_elixir:deployment-01HPMGHTG8XSYH3ZCV82SF5CEZ -image size: 126 MB - -Watch your deployment at https://fly.io/apps/hello_elixir/monitoring - -Provisioning ips for hello_elixir - Dedicated ipv6: 2a09:8280:1::2a:bc0b:0 - Shared ipv4: 66.241.124.79 - Add a dedicated ipv4 with: fly ips allocate-v4 - -Running hello_elixir release_command: /app/bin/migrate - -------- - ✔ release_command 784eee4c294298 completed successfully -------- -This deployment will: - * create 2 "app" machines - -No machines in group app, launching a new machine -Creating a second machine to increase service availability -Finished launching new machines -------- -NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling - -------- -Checking DNS configuration for hello_elixir.fly.dev - Visit your newly deployed app at https://hello_elixir.fly.dev/ ``` - -Make sure to note your Postgres credentials from the output. - +If your organization is on the [Free plan](/about/free-plan), `fly launch` can't create the cluster, because it uses the Basic plan. Create a Developer plan cluster with `fly mpg create`, then [attach it](/postgres/create-and-connect) to your app with `fly mpg attach`. That's it! Run `fly apps open` to see your deployed app in action. @@ -168,10 +72,10 @@ Try a few other commands: * `fly logs` - Tail your application logs * `fly status` - App deployment details -* `fly status -a postgres-database-app-name` - Database deployment details +* `fly mpg status` - Database cluster details * `fly deploy` - Deploy the application after making changes -To recap, the `fly launch` command detected that we are using Phoenix, set up a Fly app, created a Fly Postgres app and configured it for us, updated our Dockerfile, and created special modules and scripts to run ecto migrations for us! +To recap, the `fly launch` command detected that we are using Phoenix, set up a Fly app, created a Managed Postgres cluster and attached it for us, updated our Dockerfile, and created special modules and scripts to run ecto migrations for us! ### Storing secrets on Fly.io From 417cd6088645f43a2f25d5d19e49fd2457b1607b Mon Sep 17 00:00:00 2001 From: Alex Leventer Date: Sun, 22 Nov 2026 11:46:45 -0800 Subject: [PATCH 2/2] Give Free plan readers a working Managed Postgres path --- elixir/getting-started/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elixir/getting-started/index.mdx b/elixir/getting-started/index.mdx index 2ede1303ec..9c72e71c07 100644 --- a/elixir/getting-started/index.mdx +++ b/elixir/getting-started/index.mdx @@ -47,6 +47,8 @@ cd hello_elixir fly launch --db=mpg ``` +If your organization is on the [Free plan](/about/free-plan), `fly launch --db=mpg` can't create the cluster: launch uses the Basic plan, and the Free plan includes only the Developer plan. Instead, run `fly launch --no-db --no-deploy`, create a Developer plan cluster with `fly mpg create`, [attach it](/postgres/create-and-connect) with `fly mpg attach `, and then run `fly deploy`. + You'll get a summary of the defaults chosen for your app, including a Managed Postgres cluster on the Basic plan, and the launcher asks whether you want to tweak these settings. Type `y` to open the Fly Launch page and change the app name or region, or `n` to accept the defaults. Once you confirm your settings, the launcher will: @@ -64,8 +66,6 @@ The output ends with the URL of your deployed app: Visit your newly deployed app at https://hello_elixir.fly.dev/ ``` -If your organization is on the [Free plan](/about/free-plan), `fly launch` can't create the cluster, because it uses the Basic plan. Create a Developer plan cluster with `fly mpg create`, then [attach it](/postgres/create-and-connect) to your app with `fly mpg attach`. - That's it! Run `fly apps open` to see your deployed app in action. Try a few other commands: