Need help 502 bad gateway and nothings working!

Hey guys I have an app Im uploading to an ec2 instance with mupx and all that is going well I was using a remote db but Ive switched to local for testing. I am trying to use ssl and am getting an error when connecting to the site and when trying to use a form on the site.

The error in the nginx logs is:
[error] 17802#17802: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream

No matter what I do nothing is fixing this, I am having a hard time debugging it and am at my wits end. I can get any logs or anything for someone who is willing to take some time to help me fix this.

This site is supposed to be live so this is kinda beyond an emergency. Thanks.