If you opened your wp-content/error_log file only to find it filled with line after line of repeating PHP startup warnings, you are not alone. One of the most persistent background warnings on WordPress sites looks like this:
[14-Jul-2026 12:06:00 UTC] PHP Warning: PHP Startup: session.gc_divisor must be greater than 0 in Unknown on line 0
While this warning rarely crashes a website, it can quickly bloat your server’s error_log file to hundreds of megabytes, taking up precious disk space and masking real critical errors.
In this guide, we’ll explain the simple math behind why this error happens and walk through the exact steps to eliminate it for good.
Why Is This Warning Happening?
To keep your server from filling up with old temporary user data, PHP runs an automated cleanup routine called Garbage Collection (GC). Every time a visitor loads a page on your blog, PHP calculates whether it should sweep the server’s session folder using a simple math formula:
$$\text{Probability of Cleanup} = \frac{\text{session.gc\_probability}}{\text{session.gc\_divisor}}$$
The Problem: Division by Zero
If your hosting server’s default configuration leaves session.gc_divisor set to 0, PHP attempts to calculate the probability and realizes it is trying to divide by zero—a mathematical impossibility.
Because PHP cannot complete the equation when initializing a page request, it throws the PHP Startup: session.gc_divisor must be greater than 0 warning directly into your log file before the page even finishes loading.
How to Fix It (3 Proven Solutions)
Depending on your server architecture, here are the three ways to ensure session.gc_divisor is set to a valid number greater than zero (typically 100 or 1000).
Method 1: Update Your .user.ini File (Best for FastCGI / PHP-FPM)
Most modern WordPress hosts use FastCGI or PHP-FPM. In these environments, PHP configuration rules should be placed in a .user.ini file located in your root WordPress directory.
(If you are unsure how to connect to your site to edit this file, check out our guide on how to connect via Core FTP LE).
- Open (or create) the
.user.inifile in your WordPress root directory. - Add or update the following session lines:
Ini, TOML
; Fix PHP Session Garbage Collection Settings
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 28800
- Save and upload the file back to your server.
Important: Do not add these
php_valuedirectives directly into your.htaccessfile if you are on a FastCGI server, as this will trigger an Apache crash. Read our post on why .htaccess rules cause 500 Internal Server Errors for details.
Method 2: Force Settings in wp-config.php (Instant Override)
If your web host ignores .user.ini files or caches them on a delay, you can force WordPress to set these parameters at the application level every time PHP boots up.
- Connect to your server via FTP and open
wp-config.php. - Scroll down near the bottom, right above the line that says
/* That's all, stop editing! Happy publishing. */. - Paste these two runtime override lines:
// Force valid session garbage collection math
@ini_set('session.gc_probability', '1');
@ini_set('session.gc_divisor', '1000');
- Save and re-upload the file.
Method 3: Edit php.ini via cPanel (MultiPHP INI Editor)
If you have access to cPanel or a VPS control panel:
- Log into your hosting dashboard and open MultiPHP INI Editor.
- Select the domain or path for your WordPress installation.
- Locate
session.gc_divisorand change its value from0to1000. - Set
session.gc_probabilityto1. - Save changes.
How to Verify the Fix
Because error_log files only append new entries and never auto-delete past warnings, existing lines will remain until you clear them manually.
- Clear the Log: Open your
wp-content/error_logfile via FTP, delete all text inside, and save it as a 0-byte blank file (or delete the file entirely so WordPress can regenerate it). - Trigger Page Loads: Open a fresh browser window and click through 3 to 4 pages on your blog.
- Check FTP: Refresh your FTP directory. If the
error_logfile remains empty (or does not reappear), the warning is officially resolved!
Summary
By ensuring session.gc_probability is set to 1 and session.gc_divisor is set to 1000, you give PHP a clean $1/1000$ ($0.1\%$) chance of running session maintenance on any given page view. This satisfies PHP’s mathematical requirements, stops startup warnings from firing, and keeps your server logs clean and easy to read.
Bizeem's How to Connect Core FTP LE to Your WordPress Site
[…] Inspecting Error Logs: You can navigate to wp-content/error_log to troubleshoot silent PHP errors. If you see repeating warnings in your log, read our full guide on how to fix the PHP session.gc_divisor startup warning in WordPress. […]
Fixing the 500 Internal Server ErrorCaused by .htaccess Rules
[…] via .user.ini or wp-config.php, you can safely clear out annoying server warnings, such as resolving the session.gc_divisor error log warning in WordPress, without risking an Apache […]