Class 'Fideloper\Proxy\TrustProxies' not found after a Laravel upgrade
Class 'Fideloper\Proxy\TrustProxies' not foundShort answer
Your app still points at the old Fideloper package, which Laravel no longer needs. Laravel ships its own Illuminate\Http\Middleware\TrustProxies. Change your middleware to extend that class, or in Laravel 11 and newer delete the file and set trusted proxies in bootstrap/app.php. Do not reinstall the old package.
Fix it fast
1Find out which cause you have
Find every place the old class is still mentioned.
grep -rn "Fideloper" app bootstrap config composer.json2Match what you see, then jump to its fix
- 1
The stack trace points at app/Http/Middleware/TrustProxies.phpapp/Http/Middleware/TrustProxies.php still extends the Fideloper classFix - 2
There is no App\Http\Kernel, or a leftover reference to the old middleware class in bootstrap/app.phpThe app uses the Laravel 11+ structure, where trusted proxies are set in bootstrap/app.phpFix
- 1
What does the error look like?
Class 'Fideloper\Proxy\TrustProxies' not found
Cause 1 of 2
app/Http/Middleware/TrustProxies.php still extends the Fideloper class
1Check
Open the file and read the line that starts with use Fideloper.
sed -n '1,15p' app/Http/Middleware/TrustProxies.php2Fix
The Fideloper README says Laravel 5.5 and newer include this package and that you should not use it on Laravel 9. Extend the framework class instead.
use Illuminate\Http\Middleware\TrustProxies as Middleware;3Verify
Clear caches and load any page.
php artisan optimize:clearConfirmed by github.com
Cause 2 of 2
The app uses the Laravel 11+ structure, where trusted proxies are set in bootstrap/app.php
1Check
Search the bootstrap file for TrustProxies.
grep -n "TrustProxies\|trustProxies" bootstrap/app.php2Fix
Remove the leftover reference and configure the proxies with the trustProxies method. Use at: '*' only when you cannot list your load balancer addresses.
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})3Verify
Request a page through the load balancer and check that generated links use https.
php artisan tinker # then run: url('/')Confirmed by laravel.com
How do I stop it coming back?
- After a major Laravel upgrade, run the grep above and remove old package names from code and composer.json.
- Do not run composer require fideloper/proxy to silence the error.
- Keep proxy settings in one place, bootstrap/app.php on Laravel 11 and newer.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix