Help deploying Phoenix -> Runtime and compile time values don't match

This is an existing Phoenix app on Trying to deploy a new release (flyctl deploy) and I get this error.

The differences between the two configs comes from my runtime.exs. I’m fairly new to Elixir and Phoenix. How do I resolve this?

--> This release will not be available until the release command succeeds.
         Starting instance
         Configuring virtual machine
         Pulling container image
         Unpacking image
         Preparing kernel init
         Configuring firecracker
         Starting virtual machine
         Starting init (commit: f447594)...
         Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
         no label, UUID=8d82dbc4-fe78-430d-871e-9bbc834ad618
         Preparing to run: `/app/bin/migrate` as nobody
         2022/12/30 21:51:59 listening on [fdaa:0:d6a7:a7b:a593:11c0:b8f6:2]:22 (DNS: [fdaa::3]:53)
           * Compile time value was set to: [url: [host: "localhost"], render_errors: [formats: [html: IterupWeb.ErrorHTML, json: IterupWeb.ErrorJSON], layout: false], pubsub_server: Iterup.PubSub, live_view: [signing_salt: "xxxxxxx"], cache_static_manifest: "priv/static/cache_manifest.json"]
         To fix this error, you might:
           * Make the runtime value match the compile time one
           * Recompile your project. If the misconfigured application is a dependency, you may need to run "mix deps.compile iterup --force"
           * Alternatively, you can disable this check. If you are using releases, you can set :validate_compile_env to false in your release configuration. If you are using Mix to start your system, you can pass the --no-validate-compile-env flag
         Crash dump is being written to: erl_crash.dump...done
         Starting clean up.
Error release command failed, deployment aborted

Hi @rgraff,

I realize you’ve probably moved past this issue by now! But here’s some info in the hopes it may help future devs like yourself!

I can’t be sure, but from the error message, it leads me to believe that the [host: "localhost"] setting is the issue. In the fly.toml file, it should have a PHX_HOST value where you can specify what the host URL is for your app. This is used when writing URLs for redirects or generating full URL paths.

Then the runtime.exs file would have a section like this:

  host = System.get_env("PHX_HOST") || ""
  port = String.to_integer(System.get_env("PORT") || "4000")

  config :web, Web.Endpoint,
    url: [host: host, port: 443, scheme: "https"],
    http: [
      # Enable IPv6 and bind on all interfaces.
      # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
      # See the documentation on
      # for details about using IPv6 vs IPv4 and loopback vs public addresses.
      ip: {0, 0, 0, 0, 0, 0, 0, 0},
      port: port
    secret_key_base: secret_key_base

Where the host comes from the ENV and is used for the config.

Please note that newly generated Phoenix applications do it this way and I believe fly launch adds the PHX_HOST entry in the fly.toml file.

Hi Mark, thanks for the help. I did resolve this issue on my own.

For the benefit of other finding this thread, I was missing some ENV values in the docker image where the app was being compiled. I had some values locally in dev and in production but not in the container as the app was being compiled.


1 Like