I get an odd 502 error on my hosted site.

Posted April 3, 2018 1.1k views

Hi all- I’m getting a funny error. I have an index.php file as the default landing page for my site, and it redirects to my blog on This is all it is:

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location:" );

I was told this error started popping up around the new year (I rarely check the site, obviously). Has anyone seen anything like this before? What’s funny is that the index.html file on the site works (it’s a very old site, and I keep it around for historical purposes), so I know the server is working. Thanks!

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

A 502 error is returned when a web server cannot reach an upstream service needed to load the site. Based on this being a PHP site returning a 502 I would guess that you are running Nginx+PHP-FPM on your site rather than Apache with mod_php.

If that is the case then this would indicate that your php-fpm service either isn’t running or is returning an error. On Ubuntu you can find the logs for this process in /var/log/php-fpm

If this domain only redirects to your blog and does not serve any other content you can simplify things. PHP would not even be necessary. You can create a 301 redirect directly in your nginx configuration /etc/nginx/sites-enabled/default by following this guide.

by Mateusz Papiernik
HTTP redirection is a way to point one domain or address to another. There are a few different kinds of redirects (301 Moved Permanently and 302 Found), each of which mean something different to the client browser. You can add a redirect with `rewrite ^/$ redirect;` or `rewrite ^/$ permanent;` in your server configuration. This guide will cover a more in depth explanation of how to implement each kind of redirect in Nginx.

Thanks for the info, ryanpq. I’m running Nginx but I’m not sure with what else. I’ve done some server maintenance before but it’s been a while, so I’m not familiar with this setup.

I don’t have a php-fpm file/dir in that location, either. I did a “find” and nothing with the name fhp turns up from my root dir.

As it is, I don’t want all queries to redirect, just ones to the main url. So if they just go to it sends them to my blog, but if they add index.html to the URL they can see the site. It’s a weird setup but I’m contractually obligated to do this. :/