I'm deploying on aws with edeliver. The deploys run fine, but when I try to access the site in the console with curl localhost:8888
, I get a connection refused
error.
If I try to start the app with ./rel/bin/app_name console
, I get a (RuntimeError) expected the PORT environment variable to be set
. However my config/prod.exs
looks like this.
use Mix.Config
config :elixir_deploy, ElixirDeployWeb.Endpoint,
load_from_system_env: true,
http: [port: 8888],
ssl: false,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
config :logger, level: :info
import_config "prod.secret.exs"
What am I missing here? It works if I set a PORT=8888
before the manual start, but I'd rather start automatically with edeliver
You need to set load_from_system_env
to false
(or just remove that line). When it's true
, Phoenix's default generated endpoint.ex
will use the value of the PORT
environment variable, and if it's not found, it'll raise an error.
if config[:load_from_system_env] do
port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
{:ok, Keyword.put(config, :http, [:inet6, port: port])}
else
{:ok, config}
end