I’ve freshly installed Chef Server 12.7.0 on Ubuntu 16.04 LTS and opscode-erchef kept getting restarted approx every 40 seconds and was getting Bad Gateway error.
Checked the logs unfortunately, couldn’t conclude anything out of it. Found this open issue with Chef https://github.com/chef/chef-server/issues/435
By cleaning and re-configuring the server everything worked.
$ chef-server-ctl cleanse
$ chef-server-ctl reconfigure