// Web Development //

[Solved 2022] Upgrading to Laravel 9 “Undefined Constant” Error

by Dillon - Updated -

Have you upgraded your Laravel application to Laravel 9 and received the “Undefined Constant llluminate\Http\Request::HEADER_X_FORWARDED_ALL” error when running composer update?

It’s easy to miss on the official Laravel upgrade guide. The Laravel team state the likelihood of impact for this error is low, and thankfully it’s a quick and easy fix. 

In this post you will understand what has changed under the hood of Laravel and its dependencies. You will learn how to fix the error “Undefined Constant llluminate\Http\Request::HEADER_X_FORWARDED_ALL” when running composer update.

What’s changed in Laravel 9?

The change comes from the Symfony HttpFoundation component used by Laravel. Laravel previously used HEADER_X_FORWARDED_ALL constant for the value of the $headers property in the TrustProxies.php file, however since Symfony 5.2 this was deprecated, and finally removed in version 6.0.

When upgrading to Laravel 9, composer upgrades dependencies aswell. When the Symfony HttpFoundation package is upgraded, the Undefined Constant llluminate\Http\Request::HEADER_X_FORWARDED_ALL error is thrown.

Solution to fix the Laravel 9 Undefined Constant error

Follow the steps below to fix the Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL error.

Within your app open /Http/Middleware/TrustProxies.php  and update line 5.

Use Fideloper\Proxy\TrustProxies as Middle;

Change this line to: 

Use Illuminate\Http\Middleware\TrustProxies as Middleware;

Next, you need to update the $headers property. 

protected $headers =






And finally, you can remove fideloper/proxy composer dependency from your application: 

composer remove fideloper/proxy

You can read more about the changes required when upgrading to Laravel 9 in the official upgrade guide under the Trusted Proxies subheading.


Related Posts

Dillon Smart

👋 Hey, I'm Dillon!

I'm a Full Stack developer from the U.K. I've been building websites and applications for 11 years! Along the way I've picked up a few things, and share them here on

Feel free to reach out on Twitter!

0 Comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.