In this tutorials, I am going to show how to set/change Tomcat session timeout in Spring boot application.

Spring Boot Tomcat session timeout :

We should be able to set the server.session.timeout in or application.yml file.

server.session.timeout = 5000 // Session timeout in seconds

Most of the cases the above configuration will work, If not you should set the cookie max age along with session time out like below.


Reference :

Spring boot config

Happy Learning 🙂


  1. Enoch May 22, 2018 at 1:57 pm - Reply

    Hi chandrashekhar,
    I ´ve just used the server.session.timeout in my file and it worked. Thanks

  2. krishna September 13, 2018 at 11:58 pm - Reply

    in my spring boot application i have configured both server.session.cookie.max-age=60 and server.session.timeout=60.
    but still the session is not getting expired. i am not sure whether i am missing other configuration..

  3. PJD November 7, 2018 at 1:19 am - Reply

    Krishna, it depends on what version of Spring Boot you are using. The server.session.timeout no longer works in Spring 2.x, which requires server.servlet.session.timeout. Keep in mind this will only work in embedded Tomcat, not standalone. For that, you have to manually set the session timeout in the Tomcat server.xml. Having said all that, my session also doesn’t timeout even when setting it to 2 minutes and waiting 5 minutes. I’ve tried all the settings related to this and so far nothing works. That’s why I’m read this page.

  4. Bob March 5, 2019 at 3:47 am - Reply

    Not working for me too in Spring 3.x
    timeout: 60
    max-age: 60

  5. Majid Ali Khan November 19, 2020 at 7:22 pm - Reply

    This property was updated as of Spring Boot 2.0, now this is


    this an example value 30m

    If a duration suffix is not specified, seconds will be used.

Leave A Comment