`mix phx.server` does not work on PROD but works on DEV

Background

I am toying with PhoenixLiveView a little and I have my demo app ready to go. When I test it in DEV, it all works wonders. But if I run MIX_ENV=prod mix phx.server then the page doesn’t even load.

Code

I am aware both my config/dev and config/prod differ significantly, therefore I can only assume the issue is in my config/prod. However, being a first time user of this framework, I don’t just want to replicate my config/dev file into the prod one, I actually want to know what is missing so I can fix it.

config/dev:

import Config

config :demo, DemoWeb.Endpoint,
  http: [port: 4000],
  debug_errors: true,
  code_reloader: true,
  check_origin: false,
  watchers: [
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch-stdin",
      cd: Path.expand("../assets", __DIR__)
    ]
  ]

# Watch static and templates for browser reloading.
config :demo, DemoWeb.Endpoint,
  live_reload: [
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"priv/gettext/.*(po)$",
      ~r"lib/demo_web/(live|views)/.*(ex)$",
      ~r"lib/demo_web/templates/.*(eex)$"
    ]
  ]

# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20

# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

config.prod:

import Config

config :demo, DemoWeb.Endpoint,
  url: [host: "localhost", port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json"

# Do not print debug messages in production
config :logger, level: :info

Questions

  1. What is missing in my prod configuration?

If this is not the issue … than I am more lost than I initially thought. For those of you curious enough, here is the project:

https://github.com/Fl4m3Ph03n1x/live_view_demo

You haven’t configured on which port should your application listen in production environment. It is configured that it know that it is accessible at http://localhost/ but it doesn’t listen on any port (there is no :http nor :https configuration entry).

Additionally you cannot listen on restricted ports without making the application run as a superuser (or with privileges), at least not in the “regular way”. You probably wanted to listen on different port and then use reverse proxy to handle connections coming at 80.

Could you also post your config/prod.secret.exs file? Sounds like you might not have server set to true.

From the Phoenix document:

Open up config/prod.secret.exs and you should find a section about “Using releases” with a configuration to set. Go ahead and uncomment that line or manually add the line below, adapted to your application names:

config :my_app, MyApp.Endpoint, server: true