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

jkdesign1's avatar

Horizon 403 in Public, Gate Problem

Hey everyone,

This feels like a strange issue to me because I could have sworn everything was fine a couple of weeks ago and now I'm running into an issue with Horizon giving me a 403 in production. I've got the Service Provider and gate all set but it seems like the user is always null so I'm logged in as me, and the $user is null so I get a 403.

Everything was fine a couple of weeks ago, I'm not sure if I changed something or if something changed in Horizon. Anyone having this issue?

I saw this Horizon issue and this workaround https://github.com/laravel/horizon/issues/563#issuecomment-500821983 but unlike the folks in that thread I need only authorized users to access this, so I can't just set it to true and my user to null but that did show me that my user is always null when it hits that gate

0 likes
3 replies
bobbybouwmann's avatar

Do you have an authenticated user in any of the other middlewares? I don't have any issues with Horizon at this point so it's hard to help you with this!

malogajski's avatar

Ok this is old post but here is my example solution. Here I just allow access for all users with role ID=1.

  • remove gate function.
  • add authorisation
protected function authorization()
    {
        Horizon::auth(function ($request) {
            if (auth()->check()) {
                return auth()->user()->roles()->first()->id === 1;
            }
            return false;
        });
    }
ianflanagan1's avatar

Also check the production .env file has APP_DEBUG=false

Please or to participate in this conversation.