Fix 0X000008B9 security cache segment error on SQL Server
This error pops up when SQL Server can't grow its security session cache. The fix is usually a memory or setting tweak.
What's this error about?
Error 0X000008B9 (also called NERR_CanNotGrowSegment) shows up in the SQL Server error log. It means the security session cache — where SQL stores active logins and permissions — ran out of room to grow. This usually happens when you have a lot of connections, like during a busy hour with hundreds of users trying to log in.
I've seen this on SQL Server 2016 and 2019, especially on Windows Server 2016 and 2019. It's not a hardware failure. It's a configuration problem. You can fix it without reinstalling anything.
Quick fix (30 seconds) — Clear the session cache
This is the first thing to try. It won't fix the root cause, but it gets things running again fast. You'll need SQL Server Management Studio (SSMS) or sqlcmd.
- Open SSMS and connect to your SQL Server instance.
- Open a new query window (Ctrl+N).
- Type this command and press F5 to run it:
DBCC FREESESSIONCACHE - You should see a message like:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.No errors means it worked. - Check the SQL Server error log (right-click on the server in Object Explorer, then choose 'SQL Server Logs'). Look for new entries. The error should stop appearing.
This clears the security session cache right away. But the cache will fill up again. So you have to do one of the fixes below to make it stick.
Moderate fix (5 minutes) — Increase max server memory
The most common reason the cache can't grow is that SQL Server is running out of memory. The cache needs space inside SQL Server's buffer pool. If you set max server memory too low, the cache can't expand.
- In SSMS, right-click your server name and choose 'Properties'.
- Go to the 'Memory' page.
- Look at 'Maximum server memory (in MB)'. A typical setting for a 16 GB server is 12000 MB (leaving 4 GB for the OS). If you have 32 GB RAM, set it to 28000 MB.
- Increase the value by 10-20%. For example, if it's 8000 MB, change it to 9600 MB. Click OK.
- You don't need to restart SQL Server. The change takes effect immediately.
- After a few minutes, check the error log again. The 0X000008B9 error should stop.
Why this works: SQL Server needs memory to store the security cache. If max memory is too low, the cache can't grow when you have many connections. I've fixed dozens of servers by just bumping up max server memory by 2-4 GB.
Advanced fix (15+ minutes) — Tune the cache size and look for memory pressure
If the error still shows up after increasing memory, you need to dig deeper. This fix involves checking memory pressure and adjusting a hidden setting.
Step 1: Check for memory pressure
Run this query in SSMS:
SELECT counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name IN ('Target Server Memory (KB)', 'Total Server Memory (KB)');
If 'Total Server Memory' is close to 'Target Server Memory' (within 5-10%), your SQL Server is under memory pressure. That's why the cache can't grow. You need to either add more RAM to the server or reduce other memory consumers (like SQL Agent jobs running at the same time).
Step 2: Increase the security cache size manually (advanced, use with caution)
There's a hidden registry setting that controls the max size of the security cache. Only do this if you've already increased max server memory and the error persists.
- Open Regedit as Administrator (click Start, type 'regedit', right-click and choose 'Run as administrator').
- Go to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters - Right-click in the right pane, choose New -> DWORD (32-bit) Value.
- Name it
MaxCachedSids. Leave the value at 0 (zero) — the default is 0 which means unlimited. But here's the trick: if you set it to a positive number like 50000, it forces a larger cache limit. - Double-click the new value and set it to 50000 (decimal). Click OK.
- Restart the SQL Server service.
Warning: This is a Windows registry setting, not SQL Server. It affects the LanmanServer (the Server service). Only do this if you've tried everything else. I've seen it fix the error on servers with 500+ concurrent connections.
Step 3: Reduce connection pooling timeouts
Sometimes apps hold connections open longer than needed. This fills the cache faster. Check if your applications use connection pooling with a short 'Connection Lifetime' setting (like 30 seconds). That can cause rapid login attempts and cache growth. Ask your devs to increase connection lifetime to 300 seconds (5 minutes) or more.
When to call for help
If none of these fixes work, you might have a corrupt security database or a Windows update issue. I've seen a specific Windows Update (KB5001402 from April 2021) cause this error on SQL Server 2017. Check your installed updates. Uninstall that one if you have it, then reboot.
Also, check if you're running SQL Server in a virtual machine with dynamic memory. That can confuse SQL Server's memory manager and cause the cache to hit a wall. Set a fixed memory reservation for the VM.
Prevent it from coming back
- Monitor memory usage with Performance Monitor. Watch the 'SQL Server: Memory Manager\Total Server Memory (KB)' counter.
- Set a scheduled job to run
DBCC FREESESSIONCACHEonce a day during low usage hours, like 3 AM. - Keep Windows and SQL Server up to date. This error is less common on SQL Server 2019 CU12 and later.
That's it. You should be able to get rid of error 0X000008B9 with one of these steps. Start with the quick fix, then move to the moderate one. The advanced fix is for stubborn cases only.
Was this solution helpful?