phollyer
Unable to access Phoenix app after deployment to Ubuntu 18.04
I have set up a new Ubuntu 18.04 server and have built and released my phoenix app to production without any problems.
I can ping it with edeliver, and the logs show it as being alive.
When I try and access it over HTTP I am receiving a 502 Bad Gateway error which I assume is something to do with either my Nginx setup or Ubuntu, but I really don’t know.
I initially posted in SO because I figured the problem was more related to Ubuntu or Nginx, the question is here: https://stackoverflow.com/questions/61808572/502-bad-gateway-elixir-phoenix, with more detailed information. I’m sure people around here have the process macked, so if someone can help me here, I would be truly grateful as I’m now at a dead end.
I have posted a Gist detailing all the steps I have taken here: Setup Ubuntu 18.04 server for Elixir Apps behind Nginx · GitHub
If anyone can help me I would greatly appreciate it, I will keep the SO question, the Gist, and this post in sync with each other wrt to any solution provided.
I can provide whatever additional information is required.
Thanks
Marked As Solved
phollyer
I have been able to resolve this as follows:
There were two problems that required fixing.
- Adding
config :app, AppWeb.Endpoint, server: trueto eitherprod.secret.exsorprod.exswas required. - I had a running process left over from mistakenly deploying
stagingto the same server, initially. I originally logged in to the server, and stopped staging with./bin/app stop, maybe this left a process running, maybe somehow I started the process by mistake later on. Anyway, I usedps uxto list the running processes and found that one of the processes listedstagingin its path, so I killed all running processes related to the deloyment, both staging and production, withkill -9 processId, re-deployed to production, and all is now fine.
Also Liked
Ninigi
Now we understand each other!
Even though I am not sure I can agree… Unless you admit I was right first! ![]()
sfusato
Open up
config/prod.secret.exsand 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
This is from the Phoenix Guide about deploying with releases.
outlog
open up the port in ufw and see if phoenix is running - check the logs - I suspect csrf/origin issues since you have “127.0.0.1” as host in phoenix config (you can try host: nil to get going)
once phoenix is confirmed as running properly the next step is nginx
I’m not up to date on nginx - but if it doesn’t work try making it look like Nginx site config · GitHub from:
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









