# Trouble with stale sessions? could not allocate new session in SSL session

**URL:** <https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761>\
**Category:** Self-hosting\
**Created:** [September 29, 2021, 2:27pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761 "2021-09-29T14:27:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [September 29, 2021, 2:27pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761/1 "2021-09-29T14:27:48Z")

</div>

I’m not sure what’s up here; it might be a bug. I have a couple of sites that are getting spurious errors like these:

```plaintext
2021/09/29 12:46:34 [alert] 11364#11364: *1226080 could not allocate new session in SSL session shared cache "SSL" while SSL handshaking, client: x.x.42.250, server: 0.0.0.0:443

```

One one of them I contrived to increase max sessions like this:

```plaintext
  after_bundle_exec:
    - replace:
       filename: "/etc/nginx/nginx.conf"
       from: " worker_connections 768;"
       to: " worker_connections 1280;"
  after_letsencrypt:
    - replace:
       filename: "/etc/nginx/letsencrypt.conf"
       from: " worker_connections 768;"
       to: " worker_connections 1280;"

```

I thought that it had fixed it (didn’t see any such errors the next day), but now I’m seeing them again on that site.

This is somewhat out of my wheelhouse, but my best guess is that somehow a bunch of connections are staying active rather than being dropped and nginx is running out of sessions?

Both are standard installs and don’t have especially high traffic. One is a 4GB something on AWS the other an 8GB DO droplet (about 40K pageviews/day). I’ve got other sites with much more traffic and I don’t remember ever seeing this before, so I’m wondering if there is something new going on here.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [December 10, 2021, 3:11pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761/2 "2021-12-10T15:11:12Z")

</div>

This happened again. I see that the `ssl_session_timeout` is set to `1d` in `/etc/nginx/conf.d/discourse.conf`. Why is it changed to this from the [default](http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_timeout) of `10m`?

---

<div class="post-metadata">

**Author:** ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)\
**Post date:** [January 30, 2022, 7:42pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761/3 "2022-01-30T19:42:43Z")

</div>

I am seeing those in the log too - not too many but they are coming up. Did you find any info about that config change or did you change it back to a shorter timeframe for yourself?

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [January 30, 2022, 7:51pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761/4 "2022-01-30T19:51:31Z")

</div>

We could probably bump the cache size from 1MB to 40MB or so. AFAIK it needs to walk in hand with the timeout, and we did bump one without the other.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [January 30, 2022, 8:46pm UTC](https://meta.discourse.org/t/trouble-with-stale-sessions-could-not-allocate-new-session-in-ssl-session/204761/5 "2022-01-30T20:46:44Z")

</div>

That makes sense. Did changing the cache size get on someone’s list?
