Just wanted to say that I fixed the 502 gateway error. I just needed to restart nginx using sudo service nginx restart
sudo service nginx restart