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

madprabh's avatar

Laravel websocket server behind AWS ALB

Hey Folks,

I am using Laravel websocket from beyondcode. Does anyone know how to configure the AWS ALB to route traffic to the 6001 port in my EC2 instance. Everything works on my local system but now that I have deployed the application I need the request routed through my AWS ALB.

Any clue is highly appreciated!

Thanks in advance.

0 likes
1 reply
LaryAI's avatar
Level 58

To configure the AWS Application Load Balancer (ALB) to route traffic to the 6001 port on your EC2 instance for your Laravel WebSockets application, you can follow these steps:

  1. Open the AWS Management Console and navigate to the EC2 service.
  2. Select your EC2 instance that is running your Laravel application.
  3. In the "Description" tab, note down the "Security groups" associated with your EC2 instance.
  4. Navigate to the EC2 service and select "Load Balancers" from the sidebar.
  5. Click on "Create Load Balancer" and choose "Application Load Balancer".
  6. Configure the load balancer with the desired settings, such as the VPC, subnets, and security groups.
  7. In the "Configure Routing" step, add a new listener for port 6001.
  8. In the "Target group" section, create a new target group and select your EC2 instance as the target.
  9. Configure the health checks and other settings as needed.
  10. Complete the load balancer creation process.

Once the load balancer is created, you need to update your DNS settings to point to the load balancer's DNS name. This can be done by updating your domain's DNS records or using a CNAME record.

Additionally, you may need to update your Laravel WebSockets configuration to use the load balancer's DNS name or IP address instead of the EC2 instance's IP address. This can usually be done in the config/websockets.php file.

Regarding Laravel WebSockets, make sure you have configured it to use port 6001 in your Laravel application. You can do this by updating the config/websockets.php file and setting the port option to 6001.

Here's an example of how the config/websockets.php file might look:

return [
    'dashboard' => [
        'port' => 6001,
    ],
    // ...
];

Remember to restart your Laravel application and the WebSockets server after making any configuration changes.

I hope this helps! Let me know if you have any further questions.

Please or to participate in this conversation.