HTTP Error when uploading images

Every time I try to upload an image I get an Http error. I tried using the browser uploader and got a 502 Bad Gateway error. How do I fix this?