Rakib
Rakib

Reputation: 13085

Why is localhost returning "502 Bad Gateway"?

When I googled this issue, I noticed this is a common issue with nginx. But I never used nginx in my machine. I work with MAMP and occasionally with Python Bottle.

Now whether my MAMP/Python server is on or not, I always get "502 Bad Gateway" whenever the address bar URL contains the word "localhost". Hence, I am having to use "127.0.0.1" in the meanwhile.

I am really confused as I have no idea which particular event has caused this issue to start happening in my Mac OS X v10.7.5 (Lion).

Upvotes: 6

Views: 21591

Answers (3)

NDM
NDM

Reputation: 964

For MacOS users, you can enter the following command in the terminal:

dscacheutil -flushcache

Upvotes: 0

chuck
chuck

Reputation: 21

Check your /etc/nginx/site-available/default file and make sure that php7.1-fpm.sock is the proper PHP version you installed.

On line:

fastcgi_pass unix:/run/php/php7.1-fpm.sock;

Upvotes: 1

GMA
GMA

Reputation: 6096

I just had this issue myself with MAMP - visiting localhost:8888/anything gave me a 502, but 127.0.0.1 worked fine.

I discovered that it was my VPN (Hotspot Shield in this case) causing the issue (although I'm not sure why). I disconnected from the VPN and localhost works fine again.

Upvotes: 3

Related Questions