# Warning: openssl_random_pseudo_bytes(): Seed could not be generated in /var/www/app/src/Security/TokenGenerator.php on line 23

- **ID:** `php/openssl-random-pseudo-bytes-seed`
- **Domain:** php
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The OpenSSL random number generator cannot gather enough entropy to seed, typically due to a missing or empty /dev/urandom on the system, or a restrictive open_basedir configuration.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| PHP 7.4 | active | — | — |
| PHP 8.0 | active | — | — |
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |

## Workarounds

1. **Check if /dev/urandom exists and is readable: `ls -la /dev/urandom`. If missing, create it: `sudo mknod -m 644 /dev/urandom c 1 9 && sudo chmod 644 /dev/urandom`. Then restart PHP-FPM.** (80% success)
   ```
   Check if /dev/urandom exists and is readable: `ls -la /dev/urandom`. If missing, create it: `sudo mknod -m 644 /dev/urandom c 1 9 && sudo chmod 644 /dev/urandom`. Then restart PHP-FPM.
   ```
2. **If in a Docker container, ensure the container has access to the host's entropy pool by adding `--privileged` or mounting `/dev/urandom` from the host: `docker run -v /dev/urandom:/dev/urandom ...`** (85% success)
   ```
   If in a Docker container, ensure the container has access to the host's entropy pool by adding `--privileged` or mounting `/dev/urandom` from the host: `docker run -v /dev/urandom:/dev/urandom ...`
   ```

## Dead Ends

- **Increasing PHP's memory_limit or max_execution_time hoping the random generation will complete** — The error is about entropy availability, not memory or time; the system simply cannot gather enough random data. (95% fail)
- **Installing haveged or rng-tools without verifying they are actually running and providing entropy** — The service might be installed but not started, or the entropy source might be blocked by virtualization or container restrictions. (60% fail)
