WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Fix WordPress Keeps Logging Out Problem

How to Fix WordPress Keeps Logging Out Problem

Last updated on January 26th, 2015 by Editorial Staff
67 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Fix WordPress Keeps Logging Out Problem

Have you ever encountered the frustrating problem where WordPress keeps logging you out? Recently one of our users encountered this issue. She followed all the normal troubleshooting tips like deactivating plugins, emptying cache, clearing browser cookies, and even restoring WordPress from backups. None of the above worked for her. If you’re facing this issue, then we have a solution for you. In this article, we will show you how to fix WordPress keeps logging out problem also known as WordPress session timeout issue.

Why WordPress Keeps Logging Out?

In order to understand why WordPress keeps logging you out, you need to understand how the WordPress login process work.

WordPress sets a cookie in your browser to authenticate a login session. This cookie is set for the WordPress URL stored in your settings section. If you are accessing from a URL that does not match the one in your WordPress settings, then WordPress will not be able to authenticate your session.

Incorrect WordPress URL Settings

As you can see in the settings screenshot above, the WordPress URL and the Site Address are two different URLs (notice one has www. and the other doesn’t).

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

Fixing The Login Issue

A simple fix for this login issue is to make sure that you have the same URL in your Site Address and WordPress Address fields in your WordPress settings. This means that you need to choose either www or a non-www URL in the both fields.

Login to your WordPress dashboard and go to Settings » General.

Correct WordPress URL Settings

If you can’t access the admin area, then you can update these fields by editing the wp-config.php file.

Connect to your website using an FTP client, and locate the wp-config.php file in your site’s root directory. You need to download this file to your Desktop and open it in a text editor like Notepad. Add this code just above the line That’s all, stop editing! Happy blogging.

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

If you prefer to use www in URL, then use this code instead

define('WP_HOME','http://www.example.com');
define('WP_SITEURL','http://www.example.com');

Don’t forget to replace example.com with your own domain name.

Why does this solution work?

Technically speaking, www is a subdomain itself. This means that URLs with www and without it are actually two different domains.

By changing and updating the URLs to the same address, it will fix the issue.

A more detailed technical explanation of www vs naked domain is here.

Also it’s important to note that incorrect settings in WordPress Address and Site Address fields may also result into too many redirect issue in WordPress.

We hope this article helped you fix WordPress session timeout issue. If it doesn’t then checkout how to fix WordPress login page refreshing and redirecting issue.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.

67 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

60 Comments

Leave a Reply
  1. Ibukun says:
    Oct 28, 2020 at 3:50 am

    Hi, I have been getting this error whenever I try to logout of my website.

    ATTENTION: You need to provide |:| USERNAME: admin |:| PASSWORD: admin |:| to see the actual WordPress Admin Login-Area page. This has to prevent WordPress Bruteforce Attack on your Website. Thank You! — SYS. ADMIN….

    Do you know any fix or solutions?

    Reply
    • WPBeginner Support says:
      Oct 28, 2020 at 9:47 am

      That would be a different error, you likely have a security plugin having issues in which case you would want to follow our guide below:

      https://www.wpbeginner.com/beginners-guide/how-to-easily-deactivate-wordpress-plugins/

      Reply
  2. Goombah says:
    Oct 6, 2020 at 2:42 pm

    Thanks for this article. I was wondering if this could also be a theme issue, or is being logged out unrelated to that?

    Reply
    • WPBeginner Support says:
      Oct 7, 2020 at 10:10 am

      While unlikely, if there is an error with your current theme it could cause an issue.

      Reply
  3. Megan says:
    Aug 5, 2020 at 9:42 pm

    Both urls are the same, but don’t have www. Should I change that as this solution didn’t work for me. So frustrating when editing a post and then finding out nothing was saved!

    Reply
    • WPBeginner Support says:
      Aug 6, 2020 at 10:45 am

      With or without www shouldn’t matter, if our recommendation is not working we would recommend checking with your hosting provider to see if they see any issues on their end.

      Reply
      • Megan says:
        Aug 6, 2020 at 9:37 pm

        Thanks, I have contacted her, but haven’t had any response yet. She may not be operating anymore.
        It seems to be working again now, I updated some of the plugins.

        Reply
  4. Andres says:
    Feb 4, 2020 at 8:24 pm

    My solution was deactivating the Better Search Replace plugin.

    Reply
    • WPBeginner Support says:
      Feb 5, 2020 at 8:44 am

      Thanks for sharing what worked for you, not every site will have the exact same plugin cause this issue :)

      Reply
  5. Esther says:
    Jan 23, 2020 at 8:12 pm

    This broke my website, and now I can’t log back in.

    Reply
    • WPBeginner Support says:
      Jan 24, 2020 at 8:53 am

      As long as you set the correct domain this should not break your site unless there was a different underlying issue. For resolving any errors that have started appearing, you would want to go through our troubleshooting guide here:
      https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/

      Reply
  6. Håkon Berntsen says:
    Dec 30, 2019 at 6:54 am

    Worked like a charm. Interesting article that pointed out an error that I would never thought about myself. The settings was correct, but re-save it forced it to work again.

    Reply
    • WPBeginner Support says:
      Dec 30, 2019 at 11:44 am

      Glad our recommendation was able to help :)

      Reply
  7. Lu says:
    Jul 9, 2019 at 3:00 pm

    I keep getting disconnected and my URLs match. Any other solutions?
    Thanks

    Reply
    • WPBeginner Support says:
      Jul 10, 2019 at 10:26 am

      You may want to check with your host to see if there are any errors on the hosting end that could be part of the issue

      Reply
  8. Laura Ingalls Gunn says:
    Jul 6, 2019 at 9:02 am

    Hello
    My settings match and I’m still having the issue.
    I’ve also tried

    -different browsers
    -clearing cookies
    -clearing cache
    -deactivating each plugin one by one

    Any other solutions would be helpful. Thank you.

    Reply
    • WPBeginner Support says:
      Jul 8, 2019 at 1:45 pm

      Have you deactivated all of the plugins rather than one at a time and swapped themes to ensure it isn’t a conflict through one of those?

      Reply
  9. Tom Little says:
    May 17, 2019 at 7:23 pm

    I try and follow these instructions but I do not seem to get the same Screen when I visit General Settings as the one shown here (I do not see the dialogue boxes that show Site URLs).

    I am not sure if they are somewhere else but it seem to me these instructions are either outdated or I have to go another route. Any suggestions would be greatly appreciated.

    Reply
    • WPBeginner Support says:
      May 20, 2019 at 11:56 am

      If your settings area looks completely different you may be using WordPress.com instead of WordPress.org: https://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/

      Reply
  10. Ralf says:
    Feb 20, 2019 at 7:57 am

    How about multisite? There’s no such place to enter the URL. And then, after logging in many times, the login will eventually “stick”, without changing anything …

    Reply
    • WPBeginner Support says:
      Feb 20, 2019 at 11:19 am

      You would want to try the wp-config method and that should still work for multisite

      Reply
  11. Bassey Bassey says:
    Feb 12, 2019 at 4:30 am

    It worked for me….Thanks for the post.

    Reply
    • WPBeginner Support says:
      Feb 12, 2019 at 11:59 am

      Glad it was helpful :)

      Reply
  12. Lisa says:
    Sep 14, 2018 at 11:45 am

    This did not fix my issue. Are there any other solutions?

    Reply
  13. Tally Briggs says:
    Feb 24, 2018 at 5:59 pm

    I cannot even get to that settings page. I’m using safari and have only started having the problem with a site I comment on regularly, and have had no problems with for almost a decade.

    Reply
    • Jim says:
      Jan 29, 2019 at 6:09 pm

      I would try another browser to see if it’s a browser issue.

      Reply
  14. Amol karde says:
    Dec 9, 2017 at 2:38 am

    hi…thanks for sharing this informative article
    but i am finding issue in my website when i entered into dashboard i saw network admin and my website name as given when i go into network admin it will logout automatically. Please give me some solution or what i can do for logging into admin network.

    Thanking You…!!!

    Reply
  15. Seaira (really) says:
    Jul 3, 2017 at 9:21 pm

    Hi: I was using hostgator hosting for about 8 years with many websites. I had no problems installing wp and uploading paid templates in .zip from my computer.
    I switched to godaddy hosting and commenced to creating wp-real-estate 7 pro from theme forest. But after trying multiple times to upload the template, I had to give up. First tried uploading direct into the wp installation. Then tried direct into my file manager in CP. it would take about 20 minutes each time and then say : “are you sure you want to do this…and a box saying try again.
    site and url are both . I always used just in the past. Being they are the same, I never thought to change them to should I? Also I was signing in at:. I paid someone to help me and they tried signing in at:
    and said failed. So I had to change the passcode to get in that url. He has not done anything since and wonder if I should cancel the order and try again after I know why the .zip file won’t load. Maybe you can enlighten me.

    Reply
    • WPBeginner Support says:
      Jul 4, 2017 at 2:51 am

      Hi Seaira,

      Please check out our WordPress troubleshooting tips. It will help you locate the problem.

      Reply
  16. Marco says:
    Nov 21, 2016 at 7:33 am

    I had the same problem, caused by the Chrome extension WordPress Site Manager. When I turned it off the problem disappear.

    Reply
  17. Ariful Haque says:
    Nov 13, 2016 at 1:16 am

    My site has https in front-end and in the admin panel its only http. Both has www in it. But the site keep logging out. Can this http protocol be a cause?

    Reply
  18. Dimitrios Charalampidis says:
    Nov 2, 2016 at 5:39 pm

    I had to change http:// to https:// since I am using an SSL certificate and that solved the issue. The article showed me the correct path… Thanks.

    Reply
    • WPBeginner Support says:
      Nov 2, 2016 at 10:36 pm

      Hey, Dimitrios,

      Glad it helped :) You may also want to subscribe to our YouTube Channel for WordPress video tutorials.

      Reply
  19. Elena says:
    Oct 9, 2016 at 6:35 am

    It worked for me and I learned something new :). Thanks a lot.

    Reply
    • WPBeginner Support says:
      Oct 10, 2016 at 1:08 pm

      Hey Elena,

      Glad you found it useful :) You may also want to subscribe to our YouTube Channel for WordPress video tutorials.

      Reply
  20. Mukhtar Jafari says:
    Jul 11, 2016 at 12:25 am

    It did not work for me.
    The URLs are the same and again it gives me the same error.
    Any suggestion plz?

    Reply
    • PenX says:
      Jan 11, 2017 at 8:01 am

      I have same problem, did u find any solution???

      Reply
  21. Travis S says:
    Jul 6, 2016 at 3:39 pm

    My settings match and I’m still having the issue. It is horribly frustrating, it happens a couple of times a minute.
    I’ve tried
    -changing both settings to www
    -different browsers
    -clearing cookies
    -clearing cache
    -changing themes
    -now working through plugins one by one. The issue goes away if I disable all plugins.

    Reply
  22. Travis S says:
    Jul 6, 2016 at 11:36 am

    My settings match and I’m still having the issue. It is horribly frustrating, it happens a couple of times a minute.

    Reply
  23. Jonny boy says:
    Jul 5, 2016 at 9:53 am

    worked a treat thank you very much!

    Reply
  24. Kevin Green says:
    Jun 10, 2016 at 9:05 am

    Similar to Julie G above I have my wordpress installation in its own directory (to avoid conflict with an existing site in root) as described here

    therefore

    my wordpress address is
    my site address is

    The logging out problem is particularly annoying with the Appearance/Themes/Live Preview option which essentially will not work due to continued timeout/logout

    Has anyone solved this for this kind of situation?

    Reply
    • Kevin Green says:
      Jun 10, 2016 at 9:07 am

      I just noticed the site name which I had in ” has gotten lost in translation, it should read:-

      my wordpress address is
      my site address is

      Reply
    • WPBeginner Support says:
      Jun 10, 2016 at 7:37 pm

      Visit the Settings page and make sure that your WordPress Address and Site Address fields are correct.

      Reply
      • Kevin Green says:
        Jun 11, 2016 at 4:47 am

        I don’t know what happened with my attempts to quote example urls and the information on how to have wordpress run from a sub-directory but essentially my wordpress installation is in a sub-directory called wordpress & so my urls have to be:

        WordPress Address URL http://wordpress.example.com

        Site Address URL http://example.com

        Is there a fix that solves this situation short of re-installing wordpress in root

        Reply
  25. Paul Thom says:
    Apr 29, 2016 at 5:17 am

    Thank you, worked a treat..

    Reply
  26. Kaushal pal says:
    Apr 24, 2016 at 11:53 pm

    Wow….. that’s great……… thank’s…..

    Reply
  27. Sheila says:
    Feb 17, 2016 at 1:36 am

    Hi,

    I have the same URL in my Site Address and WordPress Address fields in the WordPress settings. Have never changed these settings.

    So what would be causing my issue?

    Thanks

    Reply
  28. Prabhu says:
    Jan 29, 2016 at 2:33 pm

    Hey thanks a lot. Your solution fixed my website logout issue.

    Reply
  29. Gerardo says:
    Jan 28, 2016 at 10:45 am

    Just one word: THANKS!!!!

    i have setting URL without www and all working fine.

    i Have a subdomain www, do u think it better setting both url with WWW or without?

    Thank u very much

    Reply
    • WPBeginner Support says:
      Jan 31, 2016 at 5:28 pm

      Please take a look at our guide: WWW vs non-WWW – Which which is better for WordPress SEO?

      Reply
  30. Jamie says:
    Jan 7, 2016 at 10:07 am

    I keep having this problem but it’s with HTTPs…. Anyone experienced that?

    I have my URL set in the config file. Maybe I should unset it…

    Reply
  31. Kris says:
    Nov 16, 2015 at 7:58 pm

    Spent 3 days trying to fix this, then found your article & it worked, thanks!!!

    Reply
  32. Vienna says:
    Oct 24, 2015 at 5:27 pm

    I keep being asked to log in on my blog. I checked Settings/General in my admin and do not see W/P address or Site Address.
    What am I missing ?
    I use my iPad for my blog and checked that cookies are enabled in the iPad Safari.
    Is there anything else I should do?
    This is a recent problem and I don’t know why it has happened.

    Reply
  33. Tommy says:
    Aug 11, 2015 at 12:41 am

    I swear every time I have a problem with WP, you guys solve it. WP should just redirect here :)

    Thanks as always and keep up the great work.

    Reply
  34. ray says:
    Jul 28, 2015 at 11:28 am

    great topic.. fixed my problem. I cloned the my site to a other server. On the VPS the admin is available on example.com:8080/wp-admin. I changed it and now the admin works like a charm!

    Thnks again

    Reply
  35. Louise Krohn says:
    Apr 22, 2015 at 2:39 pm

    Thanks for this web site. I am a brand new user of WordPress, so I appreciate having access to your tutorials. I have been working on this web site for a couple of weeks, and until a couple of days ago, I had not seen the “Your session has expired” comment. Both the site address and the WordPress address are the same (and have been since the beginning). So, what else could be causing this problem?

    Reply
    • WPBeginner Support says:
      Apr 22, 2015 at 9:27 pm

      Make sure that your browser settings are allowing the cookies to be stored permanently.

      Reply
  36. Trixee says:
    Apr 22, 2015 at 4:19 am

    Is there a variable in a config file I can update? The above solution doesn’t apply to me.

    Reply
  37. Julie G. says:
    Jan 21, 2015 at 6:05 pm

    What if I purposefully have my admin page in a different file for security reasons? For example, my WordPress Address URL is http://example.com/wp and my Site Address URL is http://example.com. Is there a work-around?

    Reply
  38. John Thom says:
    Oct 11, 2014 at 12:27 pm

    This solution applies to WordPress without MultiSite? When activating MultiSite WordPress gives the following message:

    Server Address:
    We recommend you change your siteurl to mydomain.org.uk before enabling the network feature. It will still be possible to visit your site using the www prefix with an address like http://www.mydomain.org.uk but any links will not have the www prefix.

    The effect of using www. in WPMS is that accessing http://mydomain.com/sample-page/ redirects users to the hompage, rather than WordPress self-correcting and redirecting to http://www. … … .

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
OptinMonster
OptinMonster
Convert website visitors into email subscribers. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
Beaver Builder Coupon Code
Beaver Builder Coupon
Get the best possible price on this easy drag-and-drop page builder plugin. From just $99 in 2020.
Unbounce
Unbounce Coupon
Get 20% OFF on Unbounce landing page and conversion platform.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.