Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

IanCallahan's avatar

Laravel 8 - All Routes 404 Only On Production

I've got a headscratcher.

My app is deployed using Forge/Envoyer on Digital Ocean. It's two application instances behind a load balancer, all set up by Forge.

The Laravel 7.3 version works fine with this setup and has been running beautifully.

However, I ran the Laravel Shift for Laravel 8. Went through all of the pull request comments and tested the application locally (via MacOS Valet). It's all working fine.

But when I deploy the upgraded application to production using Envoyer, every single route returns a 404. The application works fine on the the staging instance which is not behind a load balancer. I didn't touch any server configuration.

Here's what I've checked: -Controller namespace prefixing is still in place -I removed some comments from the web routes file -I don't see any obvious capitalization issues with class names

Does this ring any bells for anyone? Is there something I'm missing about load balancers/proxies and Laravel 8 that I missed in the upgrade guide?

I'm going to set up a parallel environment to see if I can replicate the issue but if anyone has any other ideas, I'd appreciate it.

0 likes
6 replies
IanCallahan's avatar

Thank you for your suggestion. I'm using a separate Redis instance for the session driver but it was good to double check. And the Stack post is interesting - I will try directly loading assets to see what happens.

I did put a Forge-created load balancer in front of the staging instance. It's working fine.

I also tried, per the suggestion of the illustrious @gonedark (JMac) wedging in a very simple get route at the top of my routes file. It did not work - I still got a 404. So I'm thinking there might be some issue with the load balancer, but I can't for the life of me figure out how the code changes force the issue to emerge. I'm able to revert to the previous commit just fine and the application works again.

jlrdw's avatar

After any code changes, I wonder if it's some kind cache problem.

IanCallahan's avatar

It's very strange. It's something in the way I have Laravel 8 setup that breaks everything.

I did think it might be a caching issuer but I can switch back to my last Laravel 7.3 commit and everything works right away. I tried setting up a whole new environment under a different domain - same pattern. I did notice that when the app is in the state where it only produces 404 errors, that nothing is getting logged at the application level. Thanks for your suggestions.

IanCallahan's avatar
IanCallahan
OP
Best Answer
Level 2

It turns out the issue was the APP_URL env variable. I had it set to the www version of my domain, which now redirects to the root domain without a subdomain. Worked fine with Laravel 7.3 but broke everything after upgrading to 8. I finally figured this out after changing ENV variables one by one on the staging instance until it broke.

3 likes

Please or to participate in this conversation.