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

shaiful's avatar

Broadcast from Laravel API to Redis only work when using Postman

Hi,

I have been banging my head for the last 5 hours with this.

So I am writing an API using Laravel and testing it with Postman. The consumer of the API is a separate Laravel installation without any frontend framework.

In the API side, I created an event that will broadcast to Redis. The event is triggered from a method in a Controller. This method got executed when requesting a POST route in the API.

public function store(Request $request) {
    //something else here
    //
    //

    event( new SomeEventStarted() );
}

In the Events class that implements ShouldBroadcast, the broadcastOn() method is also a simple one:

public function broadcastOn()    
{
    return new Channel('channel-name');
}

I have configured Redis on Laravel and on the server properly. To monitor Redis, I simply ran:

redis-cli
psubscribe *

So now when testing the API endpoint using Postman, the event got fired as expected as I can see the output being captured in Redis CLI.

1) "pmessage"
2) "*"
3) "channel-name-"
4) "{\"event\":\"App\\Events\\SomeEventStarted\",\"data\":{\"socket\":null},\"socket\":null}"

However, when I am consuming the API from the client-side Laravel app (localhost also) via Guzzle, the event did not fire. The controller got executed till the end normally as I can still see data inserted into the database but nothing on the Redis CLI.

Would really love to know what's happening.

Thank you.

0 likes
2 replies
shaiful's avatar

UPDATE #1: The broadcast didn't appear in the Redis CLI but got captured in laravel.log, This means the event is fired but for some unknown reason the broadcast to Redis doesn't happen. Meanwhile, no issue when testing with Postman.

shaiful's avatar
shaiful
OP
Best Answer
Level 1

Ok I have finally got around this. It was not a coding issue but server-related.

I am using Laragon for my localhost. Both API-side and client-side Laravel installations runs on it with virtual host. This was the culprit.

So what I did to make it working is to serve the client-side Laravel via php artisan serve with the web URL 127.0.0.1:8000. Then I can see the Redis publishing as expected.

I would love to hear the technical explanation behind this problem. Would it happen on a live server as well?

Please or to participate in this conversation.