Error relaunching a Phoenix 1.7.3 app

I’m getting the following Error when I try to use fly launch or subsequently fly deploy. I’ve had the app running on fly before. So far I’ve tried

  • Changing my port in my runtime.exs to 8080 from 80
  • Changing my host in runtime from to and
  • Regenerating my fly.toml and probably a few other things
  1. Did something change in the deploy process I’m not aware of?
  2. Did I or one of my team mates change something I’m not aware of?
  3. Did I have a stroke?
  4. Do the Gods hate me?

waiting for machine to be reachable on (waited 5.589355863s so far)
2024-06-07T20:13:16Z app[7843e64c264138] ord [info] INFO Main child exited normally with code: 1
2024-06-07T20:13:16Z app[7843e64c264138] ord [info] INFO Starting clean up.
2024-06-07T20:13:16Z app[7843e64c264138] ord [info][ 6.432515] reboot: Restarting system
2024-06-07T20:13:16Z runner[7843e64c264138] ord [info]machine did not have a restart policy, defaulting to restart
2024-06-07T20:13:16Z app[7843e64c264138] ord [info]2024-06-07T20:13:16.582974191 [01HZT5AAGN6CXK2YQFMB05H7R9:main] Running Firecracker v1.7.0
2024-06-07T20:13:16Z app[7843e64c264138] ord [info][ 0.050849] PCI: Fatal: No config space access function found
2024-06-07T20:13:17Z app[7843e64c264138] ord [info] INFO Starting init (commit: dec752a2)…
2024-06-07T20:13:17Z app[7843e64c264138] ord [info] INFO Preparing to run: /app/bin/server as nobody
2024-06-07T20:13:17Z app[7843e64c264138] ord [info] INFO [fly api proxy] listening at /.fly/api
2024-06-07T20:13:17Z app[7843e64c264138] ord [info]2024/06/07 20:13:17 INFO SSH listening listen_address=[fdaa:0:81e3:a7b:2ab:affe:51b2:2]:22 dns_server=[fdaa::3]:53
2024-06-07T20:13:17Z runner[7843e64c264138] ord [info]Machine started in 704ms
2024-06-07T20:13:19Z proxy[7843e64c264138] ord [error][PM05] failed to connect to machine: gave up after 15 attempts (in 9.657436889s)
2024-06-07T20:13:19Z proxy[d8dd9eeae74338] ord [info]Starting machine
2024-06-07T20:13:19Z app[d8dd9eeae74338] ord [info]2024-06-07T20:13:19.921136749 [01HZT5AB2QWCNZR2DXZXZ9NQRV:main] Running Firecracker v1.7.0
2024-06-07T20:13:20Z app[d8dd9eeae74338] ord [info][ 0.047336] PCI: Fatal: No config space access function found
2024-06-07T20:13:20Z app[d8dd9eeae74338] ord [info] INFO Starting init (commit: dec752a2)…
2024-06-07T20:13:20Z app[d8dd9eeae74338] ord [info] INFO Preparing to run: /app/bin/server as nobody
2024-06-07T20:13:20Z app[d8dd9eeae74338] ord [info] INFO [fly api proxy] listening at /.fly/api
2024-06-07T20:13:20Z app[d8dd9eeae74338] ord [info]2024/06/07 20:13:20 INFO SSH listening listen_address=[fdaa:0:81e3:a7b:2a9:5060:63a3:2]:22 dns_server=[fdaa::3]:53
2024-06-07T20:13:20Z runner[d8dd9eeae74338] ord [info]Machine started in 624ms
2024-06-07T20:13:20Z proxy[d8dd9eeae74338] ord [info]machine started in 627.384198ms
2024-06-07T20:13:20Z app[7843e64c264138] ord [info]warning: variable “port” is unused (if the variable is not meant to be used, prefix it with an underscore)
2024-06-07T20:13:20Z app[7843e64c264138] ord [info] /app/releases/0.1.0/runtime.exs:52
2024-06-07T20:13:20Z app[7843e64c264138] ord [info]20:13:20.604 [info] Running WhodapetWeb.Endpoint with cowboy 2.10.0 at :::8080 (http)
2024-06-07T20:13:20Z app[7843e64c264138] ord [info]20:13:20.606 [error] Failed to start Ranch listener WhodapetWeb.Endpoint.HTTPS in :ranch_ssl:listen([cacerts: :…, key: :…, cert: :…, alpn_preferred_protocols: [“h2”, “http/1.1”], next_protocols_advertised: [“h2”, “http/1.1”], reuse_sessions: true, secure_renegotiate: true, keyfile: ~c"/app/bin/tmp/site_encrypt_db/certs/", certfile: ~c"/app/bin/tmp/site_encrypt_db/certs/", cacertfile: ~c"/app/bin/tmp/site_encrypt_db/certs/", port: 443]) for reason :eacces (permission denied)
2024-06-07T20:13:20Z app[7843e64c264138] ord [info]20:13:20.607 [error] Error starting the child :site: {:shutdown, {:failed_to_start_child, {:ranch_listener_sup, WhodapetWeb.Endpoint.HTTPS}, {:shutdown, {:failed_to_start_child, :ranch_acceptors_sup, {:listen_error, WhodapetWeb.Endpoint.HTTPS, :eacces}}}}}
2024-06-07T20:13:20Z app[7843e64c264138] ord [info]20:13:20.609 [notice] Application whodapet exited: Whodapet.Application.start(:normal, ) returned an error: shutdown: failed to start child: SiteEncrypt.Phoenix.Endpoint

^^ The above is the error that’s causing the application to not start; permissions are wrong on those files.

Can you check where those files come from and maybe fix the permissions so they are readable by the user your app runs as?


My configs all have r permission for the owner, the group, and other. Or is that not what you mean?

The default Dockerfile for Phoenix apps has the app running as nobody. The Dockerfile has an instruction to change ownership of all files under /app to nobody. If you added steps to the Dockerfile to copy files, possibly those .pem files, into the image, ensure you put them BEFORE the line that says:

RUN chown nobody /app

If you put them after this line they might end up with the wrong owner in the built image resulting in the permission error you see.


No, that doesn’t make any difference that I can see. This is fairly old Docker file. Will it help if I just delete the Docker file and the .toml file and start from scratch?

Hi - it’s one of the things I was about to suggest, as the Phoenix app scanner/launcher has likely evolved and might be able to solve this issue directly.

If you move the fly.toml and Dockerfile out of the way (maybe don’t delete them! move them elsewhere) and rerun fly launch (you can use the same app name) you should get a new fly.toml and Dockerfile.

One other thing - once you have the Dockerfile, you should be able to docker build . --tag my-app and then docker run my-app to iterate locally on a possible solution. What you’re seeing is not likely a issue but something with permissions in the Docker image. This tip may help find the issue faster since you don’t depend on pushing and building on Fly before you can see the error :slight_smile:

  • Daniel

Now I’m getting the an Error about my DATABASE_URL. But as you can see I have an env var set. Do I need to add that to my Dockerfile?

sudo docker run whodapet
=ERROR REPORT==== 7-Jun-2024::22:03:20.721545 ===
Invalid -name given to erl,
=ERROR REPORT==== 7-Jun-2024::22:03:20.721545 ===
Invalid -name given to erl,
warning: variable “port” is unused (if the variable is not meant to be used, prefix it with an underscore)

ERROR! Config provider Config.Reader failed with:
** (RuntimeError) environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE

/app/releases/0.1.0/runtime.exs:26: (file)
(elixir 1.15.7) src/elixir.erl:396: :elixir.eval_external_handler/3
(stdlib 5.1.1) erl_eval.erl:750: :erl_eval.do_apply/7
(stdlib 5.1.1) erl_eval.erl:494: :erl_eval.expr/6
(stdlib 5.1.1) erl_eval.erl:136: :erl_eval.exprs/6
(elixir 1.15.7) src/elixir.erl:375: :elixir.eval_forms/4
(elixir 1.15.7) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(elixir 1.15.7) lib/code.ex:543: Code.validated_eval_string/3

Runtime terminating during boot ({#{message=><<101,110,118,105,114,111,110,109,101,110,116,32,118,97,114,105,97,98,108,101,32,68,65,84,65,66,65,83,69,95,85,82,76,32,105,115,32,109,105,115,115,105,110,103,46,10,70,111,114,32,101,120,97,109,112,108,101,58,32,101,99,116,111,58,47,47,85,83,69,82,58,80,65,83,83,64,72,79,83,84,47,68,65,84,65,66,65,83,69,10>>,‘struct’=>‘Elixir.RuntimeError’,‘exception’=>true},[{elixir_eval,‘FILE’,1,[{file,“/app/releases/0.1.0/runtime.exs”},{line,26}]},{elixir,eval_external_handler,3,[{file,“src/elixir.erl”},{line,396},{error_info,#{module=>‘Elixir.Exception’}}]},{erl_eval,do_apply,7,[{file,“erl_eval.erl”},{line,750}]},{erl_eval,expr,6,[{file,“erl_eval.erl”},{line,494}]},{erl_eval,exprs,6,[{file,“erl_eval.erl”},{line,136}]},{elixir,eval_forms,4,[{file,“src/elixir.erl”},{line,375}]},{‘Elixir.Module.ParallelChecker’,verify,1,[{file,“lib/module/parallel_checker.ex”},{line,112}]},{‘Elixir.Code’,validated_eval_string,3,[{file,“lib/code.ex”},{line,543}]}]})

Crash dump is being written to: erl_crash.dump…done
johnhitz@pop-os:whodapet_0.1(render-deploy)$ echo $DATABASE_URL

Docker doesn’t expose the host’s environment variables inside the container by default. You have to set them explicitly like so:

docker run whodapet --env DATABASE_URL="$DATABASE_URL"


  • Daniel