Redirected too many times / redirecting in a way that will never complete


starting a new topic because we’re deviating from the original.

Trying to get EE to work on top of an existing nginx install (after cleaning removing as much as possible) and having many problems.

  • When accessing the browser is giving “redirected too many times” (chrome) or “redirected in a way that will never complete” (mozzilla) error.

  • When accessing directly the browser shows the login screen correctly

  • After putting credentials (or clicking 'back to on the login screen, I’m redirected to the local IP (192.168.x.x), which obviously is not available from the outside

Can anyone point me in the right direction?

Thanks for any help! After two days I’m getting a bit desperate!


  • Site was set up with --w3tc

  • ee info --php comes back the user ‘empty’ (i.e. user is not www-data) (not sure if this is relevant)

  • error log shows “2017/06/13 10:41:32 [error] 8678#0: *50 connect() failed (111: Connection refused) while connecting to upstream, client:, server:, request: “GET / HTTP/1.1”, upstream: “fastcgi://”, host: “”” (not sure if this is relevant)

Some further notes:

  • I’m running a “real” machine with some other functions as well (including others sql databases), so I can’t just start a new VM

  • After trying to clean the machine (ee purge and deleting /etc/nginx and so forth) I had to put things back manually because both nginx and ee were assuming to find the various .conf files

  • EE is not reinstalling / enabling the 22222 tools - which is something I’m trying to fix by manually putting files back as well.

  • I guess the challenge is to trick EE into thinking it has to install everything from scratch… but I haven’t managed!

Hi @warner

I saw the thread posted by you and understand that you are having many issues with nginx configurations. Don’t worry, we can try some basic checks to find out where is the exact issue.

Findings: (Redirection Issue) antopjoseph@apj-mbp  ~  curl -X GET -I HTTP/1.1 301 Moved Permanently Server: nginx Date: Tue, 13 Jun 2017 11:58:26 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive Location: is redirected to causing 1st redirect. (see Location: )

and when I check

antopjoseph@apj-mbp  ~  curl -X GET -I HTTP/1.1 302 Found Server: nginx Date: Tue, 13 Jun 2017 11:58:32 GMT Content-Type: text/html; charset=utf-8 Content-Length: 48 Connection: keep-alive Location: X-Served-By: Namecheap URL Forward is redirecting again back to Causing a redirect Loop.

For easy debugging replace all occurrances of from nginx configuration and use

and make sure SITE_URL and HOME_URL in wp-config.php are same.

or use following inside your wp-config.php

define( 'WP_SITEURL', '' ); define( 'WP_HOME', '' );

@warner and regarding the error appeared in the log, most probably this would be similar to the issue specified here.

Also, since you have not installed EE on a clean machine, there might be old php-fpm running on the same port 9000. if there, you will need to uninstall all services which are not installed by EE.

(EasyEngine installation on a fresh machine is always preferred in order to avoid any conflicts between the packages/services.)

@antopjoseph thanks for the hints! now I removed from the host file and (predictably) when I to to either or nginx redirects me to the default site… So that’s not enough.

The reverse also doesn’t work (the loop is there also if I just have in the hosts file).

Any ideas what to try next?


@anto Ok. Updated /etc/php/7.0/fpm/pool.d/www.conf as follows:

  • Replaced “listen = /run/php/php7.0-fpm.sock” with “listen =”

  • Restart service by systemctl restart php7.0-fpm.service

  • Running netstat -ntualp |grep :9070 now shows: “tcp 0 0* LISTEN 32226/php-fpm.conf)”

That fixed that part (just writing it down here so that it may help others).

Only the redirect left to fix :wink:

1 Like

Ok… on the redirect issue: perhaps I need to change my DNS records?

Now I have two records:

  • An “A Record” on “Host=www” pointing to my IP

  • An “URL Redirect Record” on “Host=@” pointing to “”, unmasked.


Nice. It’s good to report your findings so that it will surely help someone in future.

Once I domain name is resolved to IP, DNS don’t have any role in redirection. and when I checked, your domain is showing nginx default page. Not redirection issue. (clear cache and check). So now make sure the document root specified is correct in configuration file (root /var/www/domain-root/htdocs) and also check the server_name is like server_name;

I removed the from the .conf file so it started referring to default. Now I put it back - but also the problem is back.

On second thought… I have another site running Piwigo on the same server, using the same nginx config, the same setup in the hosts file (i.e. both andexample.sitee in sites-available/ file) and the same dns records setup… and that site is running just fine! This makes me thing the issue is with the wp site specifically for some reason.

… I’m totally lost… :sweat:

also adding the following inside the wp-config.php file (as per your suggestion) does not make a difference…

define( ‘WP_SITEURL’, ‘’ ); define( ‘WP_HOME’, ‘’ );

However… what DID work, is changing your suggestion to:

define( ‘WP_SITEURL’, ‘’ ); define( ‘WP_HOME’, ‘’ );

That worked! It would be great to understand why though… for the benefit of the learning curve ;).

I’m so happy right now! After two days of work…


Once nginx passes the request, the further processing is managed at wordpress end. Wrong SITEURL & HOMEURL which was not matching with the specified one in nginx resulted in a loop.

when we specify WP_SITEURL and HOME_URL in wp-config.php, we are overriding similar setting in your database (wp_options table). You can change the same using PhpMyadmin. :slight_smile:

And that’s it! You can help others with the same problem in the future!

1 Like

@anto thanks so much for your help. Surely I will do my best to support others now that I know a little more about how this works.

Anyhow, it’s still a little strange: how come the default setting ( in my case, so without www) is not matching the one specified in nginx? In the sites-enabled/ both are specified. Is the core reason that the DNS sends and not That would mean that the default EE setup is not compatible with the default setup of

@warner DNS have no role in this.

VPS provided by namecheap had some services which where running on the ports which are required for the services installed by EE.(nginx/phpfpm) caused first error.

Redirection and issue related to www. can be of many reasons like mismatching. If all configurations generated by EE (in fresh VPS) this won’t happen.