Meteor website showing "Bad Gateway" for unknown reasons


We are hosting one of our website on AWS, deployed successfully without any error but sometimes for some unknown reasons it shows “BAD GATEWAY” , unable to figure out why it is so. In this case, we manually again deploy it and everything goes to normal, but the thing is we can not afford it as the website is on production and it is hampering our product. Any suggestion why this is happening. Is anyone out there experiencing the same issue? Please help me out with this.

Also, I want to confirm whether it is happening because of the following situations -

a) AWS EC-2 instance stop/start/restart
b) Memory issue

The result of df -h

  Filesystem      Size  Used Avail Use% Mounted on
  udev            2.0G     0  2.0G   0% /dev
  tmpfs           396M   41M  355M  11% /run
  /dev/xvda1       30G   24G  5.8G  81% /
  tmpfs           2.0G  1.6M  2.0G   1% /dev/shm
  tmpfs           5.0M     0  5.0M   0% /run/lock
  tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
  tmpfs           396M     0  396M   0% /run/user/1000

Update: We are using nginx as proxy and app is deployed using MUP tool.

Thanks in advance!


How are you deploying it and what do your logs say?


It sounds like it’s running behind a proxy (nginx, apache, passernger, other load balancer), is that right?
Usually bad gateway means the proxy didn’t get an answer from the upstream (the Meteor app). Which either means it’s crashed, overloaded or busy working on a long running task on the main thread

Take a look at the logs for both your Meteor app and for the proxy to see which isn’t taking to the other properly
If you can track the number of restarts for the app too, that could help


We are using nginx as proxy and app is deployed using MUP tool.


Did you check the logs using mup logs -f to ensure the app is starting correctly?


Just checked it there are some in-app consoles and one error regarding meteor method. Meteor method failed because we recently changed our mail-server and email related configuration process.env.MAIL_URL is pointing out to something older one.


So that’s the issue most likely, it’s crashing on startup…


oh god is it? Pretty new to me, need to consider it as a priority work. Hope so fixing this will work as we are having two environments one is for production and one is test. Production have only phase-1 development and test is having phase-1&2. Can not pull data from git though, I guess I can manually edit the file. Thank you for the help.