Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting

Why Does WordPress Keep Logging Me Out? Causes and Fixes

Why Does WordPress Keep Logging Me Out? Causes and Fixes

Short answer

WordPress usually keeps logging you out because the WordPress Address and Site Address do not match the URL you use, your browser blocks or loses login cookies, a cache or CDN interferes with cookies, or a security plugin ends sessions early. Login cookies also expire after two days, or 14 days with Remember Me ticked.

Key takeaways

  • Mismatched www, non-www or http and https URLs are the top cause.
  • Login cookies last two days, or 14 days with Remember Me.
  • Caching or CDN rules must never cache admin or login pages.
  • Security plugins can set short session timeouts.
  • Changing the keys and salts in wp-config.php logs everyone out.

Why does WordPress keep logging me out?

You are usually logged out because your login cookie is not reaching WordPress: the site URL differs from the one you use, cookies are blocked or cached, or a plugin or server setting ends the session.

WordPress keeps you logged in with cookies set for your site's domain and path. Anything that changes the domain, blocks cookies or strips them breaks the session.

SymptomLikely causeFirst fix
Logged out on every clickURL mismatchMatch site URLs
Logged out after a few minutesSecurity plugin timeoutCheck session settings
Logged out after two daysNormal cookie expiryTick Remember Me
Logged out only in one browserBlocked cookies or extensionsCheck browser settings
Logged out after enabling a CDNCached or stripped cookiesBypass cache for admin

Start with the URL check. It fixes most cases.

Note when the logouts happen: on every click, after a set time, only on certain pages, or only on one device. The pattern points straight to the cause.

Do your site URLs match?

The WordPress Address and Site Address under Settings > General must use the same protocol and domain version you visit, such as https with or without www, or cookies are set for the wrong address.

If you log in at one version and WordPress redirects to another, the cookie does not follow you.

Use https for both addresses once SSL is installed, and redirect all other versions to that one.

A quick test: log in, then look at the address bar. If the domain or protocol changed after logging in, a redirect is sending you to a different version of the site.

The handbook page on editing wp-config.php explains WP_HOME and WP_SITEURL, which override the dashboard settings.

If you changed domains recently, our guide on changing a site's domain covers the full set of updates.

How long do WordPress logins last?

By default, the login cookie lasts two days, or 14 days if you tick Remember Me on the login screen; after that, WordPress asks you to log in again.

The auth_cookie_expiration filter reference documents these defaults and how developers can change them.

Tick Remember Me on your own devices. Avoid it on shared computers.

If you are logged out much sooner than two days, something else is ending the session.

Do several devices log each other out?

No. WordPress allows sessions on several devices at once, so logging in on a phone does not log you out on a laptop unless a plugin limits concurrent sessions.

You can end other sessions yourself from your profile with the button to log out everywhere else.

Is your browser blocking cookies?

Browsers, privacy extensions and strict tracking settings can block or delete cookies, which logs you out on every page load or when you close the tab.

Allow cookies for your own site. Google's help page on clearing, enabling and managing cookies in Chrome shows where these settings are.

Try a private window with extensions disabled. If the problem disappears, an extension is responsible.

Some browsers clear cookies when the window closes. If you are logged out every morning, check whether cookies are set to clear on exit.

MDN's guide to HTTP cookies explains how domain, path and secure settings decide when a cookie is sent.

Are caching or CDN rules breaking logins?

If a page cache or CDN caches wp-admin, the login page or pages for logged-in users, it can serve responses without your session or strip cookies, logging you out.

Make sure caching plugins skip logged-in users and admin pages.

Server-level caches from hosts need the same exclusions. Ask your host if you are unsure how their cache treats logged-in visitors.

If you cache HTML at a CDN, add rules that bypass the cache when WordPress login cookies are present. The Cloudflare cache rules documentation shows how to add conditions.

Our guide on Cloudflare cache rules for WordPress includes safe bypass rules for admin traffic.

After changing rules, clear every cache. Our guide on clearing cache in WordPress lists each layer.

Is a security plugin ending your session?

Security plugins can set short session limits, log out idle users, block logins from changing IP addresses or force logouts after settings changes.

Check the plugin's login or session settings for idle timeouts.

Short timeouts are sometimes sensible for shop managers or shared office computers. Agree a length that balances security with convenience for your team.

If your IP address changes often, for example on mobile data, IP-locked sessions will log you out. Relax that setting for admins if needed.

Our guide on fixing Wordfence blocking admin covers one common security plugin case.

Did the keys and salts change?

Changing the authentication keys and salts in wp-config.php invalidates every login cookie, so everyone is logged out once; repeated changes cause repeated logouts.

Some security tools rotate salts automatically. Check whether that is scheduled.

If a plugin or script keeps rewriting wp-config.php, find and stop it.

Our guide on finding wp-config.php shows where the keys and salts live.

Could the server or hosting setup be the cause?

Load balancers, proxies and some hosting setups can send requests to different servers or rewrite headers, which can break the session if WordPress sees the wrong protocol or host.

If the site sits behind a proxy, WordPress may think requests are http instead of https. That breaks secure cookies.

Ask your host whether they use a proxy or load balancer, and how they recommend passing the original protocol to WordPress.

A wrong server clock can also affect expiry checks. Hosts can fix time synchronisation quickly.

Mixed content warnings can be a clue too. If parts of the dashboard load over http, the site may not know it is running on https.

Custom COOKIE_DOMAIN, COOKIEPATH or similar constants in wp-config.php must match your real domain and path, or browsers store cookies where WordPress does not look.

Remove custom cookie constants temporarily and test. Many sites never need them.

Multisite networks use cookie settings more often. Check them carefully after domain changes.

Why are you logged out when previewing posts?

Preview links use the site URL, so a URL mismatch or caching issue often shows up first as a login screen during preview.

Our guide on preview mode not working covers this overlap in detail.

What if you cannot log in at all?

If logouts turn into a login loop or a lockout, reset URLs in wp-config.php, disable plugins by renaming the plugins folder, and clear cookies for the site.

Our guide on fixing being locked out of wp-admin walks through recovery steps without dashboard access.

Once you are back in, re-enable plugins one by one to find the cause.

How do you stop logouts coming back?

Keep one canonical URL, exclude logged-in users from every cache, review security session settings, avoid unnecessary cookie constants and test logins after any CDN or hosting change.

Write down your cache bypass rules. They are easy to lose when someone edits CDN settings later.

Keep WordPress, plugins and themes updated as well. Login bugs are often fixed in routine releases.

Test in a private window after changes. It shows how a fresh login behaves.

Frequently asked questions

Why does WordPress log me out every time I click?

Usually the URL you use differs from the WordPress Address or Site Address, such as www versus non-www or http versus https, so the login cookie does not match.

How long does a WordPress login last?

By default the login cookie lasts two days, or 14 days if you tick Remember Me. Plugins and custom code can change these durations.

Can Cloudflare cause WordPress logouts?

Yes, if cache rules cache admin pages or logged-in traffic. Add rules that bypass the cache when WordPress login cookies are present.

Why am I logged out after changing wp-config.php?

If the authentication keys and salts changed, every login cookie becomes invalid, so all users are logged out once and must sign in again.

Can a security plugin log me out?

Yes. Security plugins can set idle timeouts, short session lengths or IP-locked sessions. Check their login settings if logouts happen after a few minutes.

Sources

  1. Editing wp-config.php WordPress Developer Resources
  2. auth_cookie_expiration WordPress Developer Resources
  3. Using HTTP cookies MDN Web Docs
  4. Cache Rules Cloudflare Docs
  5. Clear, enable and manage cookies in Chrome Google Chrome Help

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.