Fl4m3Ph03n1x
`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
- 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:
Marked As Solved
hauleth
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









