Kibana - Nginx 502 Bad Gateway

I tried logging into Kibana and was greeted with a 502 Bad Gateway error. Our setup is a single server hosting elastic, logstash and kibana. On the server, I got a 302 redirect when running curl -i http://localhost:5601. When I changed curl -i to curl -iL to follow the redirect, I get the 200 OK message followed by the html.

The /var/log/nginx/kibana.error.log shows "[error] 1862#1862: *815 connect() failed (111: Connection refused) while connecting to upstream" when trying from my system. I'm thinking something is up with nginx but have very little experience with it. Any suggestions to troubleshoot next?

FIXED - The config file in /etc/nginx/sites-enabled/default was set to fqdn:5601 and changing it to localhost:5601 allowed the page to load. Not sure why it stopped working other than sometimes ELK likes localhost or fqdn or 127.0.0.1 and now it liked localhost.