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

cameronscott137's avatar

Using Laravel Passport with a Load Balancer

In my Laravel app, I'm using Passport's Password Grant to give API access to an iOS application.

In my production environment, I'm also using one load balancer to distribute requests to two servers. All have been created in forge.

I can use the Password Grant token to authenticate a user via iOS, and have the API return the bearer access_token. However, the load balancer then ships the next request to the other server, which seems not to recognize the access_token, and so throws a 401.

Question #1: Does anyone have experience using Passport with a load-balanced environment? If so, did you run into this issue?

Question #2: Where is the access_token stored? I see it referenced within my database via an ID, but the token itself isn't stored there. Without, I'm not sure how to persist from server to server.

0 likes
2 replies
theProfit's avatar

I am having the same problem, going to find some more information about it. DId you find a solution?

hbgl's avatar

@theProfit Going on a hunch here, but Passport uses encryption keys to sign and encrypt stuff. You should make sure that you use the same keys for all of your servers that do authentication. While you're at it, you should probably also use the same app key.

gravedigger --> For digging up this dead thread.

Please or to participate in this conversation.