Wp login on production server

I’m running into a strange issue on a production server. I’m unable to login to the admin - there are no errors, but the redirect is back to the login. There are no plugins active and I’ve cleared cookies and cache.

I wondered if it was related to: Redirect Loop / wp-login.php w/out error msg on newly installed roots/bedrock in Apache2

and the site url and the home url were both being set to http://example.com/wp/
so I tried setting the home url directly in the database to http://example.com/ but no luck.

The issue is not happening in staging or development with the same repo and database.

I’m using trellis and sage theme. So running nginx

Any thoughts?

Multisite or normal install?

Tried using Incognito? May need to clear your cookies.

It’s a normal install - cleared cookies and tried incognito/ different browsers still nothing

Does the site use https? If your site uses both, I believe that can cause a problem sometimes as login cookies are scheme specific.

Hi - no it’s not under https the only thing I can think of is that it was provisioned using the ip, where as the staging was provisioned using the domain in the hosts file, but that has never been an issue before and I don’t know why it would effect anything.

Is there anything I can do to log and debug the issue as it is becoming more pressing?

You can try using my wp-cli login command and bypass the login form altogether :smiley:

I realize that may not solve your root issue, but if you just need to get in, that should do it for you as it doesn’t rely on the login page at all.

I’ve just deployed the live version of the site on production and this has still been an issue, but I’ve figured out why (it was my fault) but I’m not 100% sure I’ve fully cleaned up the problem.
The site is now under https btw.
I had originally provisioned the production with a redirect (wordpress_sites.yml)

  - canonical: thesitename.com
      - www.thesitename.com

Should be ok.
BUT I had a dodgy env variable too:

  disable_wp_cron: true
  wp_home: https://thesitename.com
  wp_siteurl: https://www.thesitename.com/wp
  wp_env: production

(I’d for some reason added www to the site url)
So I removed that from the setting and reprovisioned - but it still didn’t work.
So I removed the redirect and reprovisioned again and now it works - in that I can log into the admin - but the admin is at www.thesitename.com/wp
The front end of the site is at thesitename.com and if you put in www.thesitename.com it redirects correctly to thesitename.com without www

So it seems to work - apart from the admin area almost having an inverse redirect TO www.

I would have expected that by reprovisioning the settings would be correct - is there some reason the admin is still under www. even though I reprovisioned after correcting my initial error?

Thanks in advance!

Unfortunately WP stores a lot of settings in the database so I’m guessing that setting is just persisted there. You’d have to manually update the DB or re-install WP. WP-CLI has some nice commands for search + replace.

1 Like