Skip to content
Fly App performance optimization Docs
Need a Logo? View Our Brand Assets
Fly App performance optimization Docs
Pricing Support
Sign In Sign Up
Docs Index
Getting Started
  • Migrate from Heroku
  • Existing Elixir Apps
  • Legacy pre v1.6.3 Phoenix App
The Basics
  • IEx into Your Running App
  • Clustering Your Application
  • Troubleshooting
Advanced guides
  • GitHub Actions for Elixir CI/CD
  • Connecting Observer to Your App in Production
  • Connecting Livebook to Your App in Production
  • Do Interesting Things with Livebook and Your Production App
  • Easy Clustering from Home to Fly.io
  • SQLite3
--- title: Getting Started layout: framework_docs order: 1 redirect_from: /docs/getting-started/elixir/ blog_path: /phoenix-files subnav_glob: docs/elixir/getting-started/*.html.* objective: Quickly get a basic Elixir Phoenix app up and running at Fly. This is the jump-off point so start here related_pages: - /docs/flyctl/ - /docs/reference/configuration/ - /docs/postgres/ --- <div> <img src="/static/images/elixir-intro.webp" srcset="/static/images/[email protected] 2x" alt=""> </div> <%= partial "docs/languages-and-frameworks/partials/intro", locals: { runtime: "Elixir Phoenix", database: true, link: "https://www.phoenixframework.org/" } %> <div class="callout"> **NOTE:** This guide is for apps generated on Phoenix 1.6.3 or later, where deployment is streamlined significantly. If you're on an earlier version and can't upgrade, check out our **[legacy deployment guide](/docs/elixir/getting-started/legacy)**. </div> We'll be using the standard web application generated by the Elixir [Phoenix Framework](https://www.phoenixframework.org/). ## _Preparation_ If you don't already have Elixir and Phoenix installed, get them set up before starting this guide. When you [install Elixir](https://elixir-lang.org/install.html), the [Mix](https://hexdocs.pm/mix/Mix.html) build tool ships with it. You can [install](https://hexdocs.pm/phoenix/installation.html#phoenix) the Phoenix project generator `phx.new` from a [Hex](https://hex.pm/docs/usage) package as follows: ```cmd mix archive.install hex phx_new ``` ## _Generate the app and deploy with Postgres_ If you just want to see how Fly.io deployment works, this is the section to focus on. Here we'll bootstrap the app and deploy it with a Postgres database. First, [install flyctl](/docs/flyctl/install/), the Fly.io CLI, and [sign up to Fly.io](/docs/getting-started/sign-up-sign-in/#first-time-or-no-fly-account-sign-up-for-fly) if you haven't already. Now let's generate a shiny, new Phoenix app: ```cmd mix phx.new hello_elixir ``` The output ends with instructions for configuring the database and starting the app manually. The Fly.io launcher is going to take care of this, so we can ignore them. <%= partial "docs/languages-and-frameworks/partials/launch_with_postgres", locals: { detected: "Phoenix", app_name: "hello_elixir" } %> 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! ### Storing secrets on Fly.io You may also have some secrets you'd like set on your app. Use [`fly secrets`](/docs/apps/secrets/) to configure those. ```cmd fly secrets set MY_SECRET_KEY=my_secret_value ``` ### Deploying again When you want to deploy changes to your application, use `fly deploy`. ```cmd fly deploy ``` The `fly deploy` command uses a Fly.io remote builder app to build the image. You can always check on the status of a deploy: ```cmd fly status ``` Check your app logs: ```cmd fly logs ``` If everything looks good, open your app on Fly.io! ```cmd fly apps open ``` ### Important IPv6 settings The `flyctl` command attempts to modify your project's Dockerfile and append the following lines: ```Dockerfile # Appended by flyctl ENV ECTO_IPV6 true ENV ERL_AFLAGS "-proto_dist inet6_tcp" ``` If you customized your Dockerfile or launched without the Dockerfile, this setting may not have been set for you. These values are important and enable your Elixir app to work smoothly in Fly's private IPv6 network. Check for this if you encounter network-related errors like the following: ``` Could not contact remote node my-app@fdaa:0:31d4:a5b:9d36:7c1e:f284:2, reason: :nodedown. Aborting... ``` ## What's Next? Next up, [IEx into Your Running App](/docs/elixir/the-basics/iex-into-running-app/)!
Docs Elixir on Fly.io Getting Started

Getting Started