phollyer

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

phollyer

I have been able to resolve this as follows:

There were two problems that required fixing.

  1. Adding config :app, AppWeb.Endpoint, server: true to either prod.secret.exs or prod.exs was required.
  2. I had a running process left over from mistakenly deploying staging to 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 used ps ux to list the running processes and found that one of the processes listed staging in its path, so I killed all running processes related to the deloyment, both staging and production, with kill -9 processId , re-deployed to production, and all is now fine.

Also Liked

Ninigi

Ninigi

Now we understand each other!

Even though I am not sure I can agree… Unless you admit I was right first! :slightly_smiling_face:

sfusato

sfusato

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

This is from the Phoenix Guide about deploying with releases.

outlog

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:

https://medium.com/@zek/deploy-early-and-often-deploying-phoenix-with-edeliver-and-distillery-part-two-f361ef36aa10

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement