Support the ongoing development of →

Deploying Soketi to Laravel Forge

6 Jan, 2022 3 min read 269 views

Soketi is a simple, fast, and resilient open-source WebSocket server written in Typescript. It's fully compatible with the Pusher v7 protocol which makes it a viable replacement to Pusher when using Laravel Echo.

In this blog post we're going to learn how to deploy Soketi to a server managed by Laravel Forge. We suggest using the "Web Server" server type when creating this server in Forge as Web servers include Node, NPM, and Nginx.

Opening Ports

After creating the server, we need to open port 6001 on the server so that the PusherJS / Echo client can connect to the Soketi server that we will install later.

To open the port, head over to the Network panel in Forge, create a new Rule named “Soketi Server”, and set the port to 6001. The Rule Type should be set to "Allow".

Opening Port 6001

Installing Soketi

Before we can run Soketi, we need to install it on our server. Because Soketi is an NPM package, we can run the following command to install it:

npm install -g @soketi/soketi

Alternatively, you may use Yarn to install Soketi.

We can verify that Soketi is installed by running soketi start in the terminal. If Soketi is not installed or its default port of 6001 is in use then you may receive an error when executing the start command.

Configuring The Daemon

After installing Soketi, we can configure a Daemon on our server that will keep the service running and restart it if it crashes.

Let's head over to Forge, then navigate to the server's Daemons panel. To create the Daemon, there are a couple of things we need to do:

  1. Set the Command to soketi start
  2. Change the Stop Seconds to 60
  3. Change the Stop Signal to SIGINT

Creating The Soketi Daemon

Once created, we can verify that Soketi is running by clicking the three dots next to the Daemon in the "Active Daemons" table and then clicking the "Show Daemon Log" button.

Checking The Soketi Service

Great! Soketi is running perfectly.

For a more advanced setup instructions, check out the Soketi documentation. You may modify the command to change drivers, enable SSL support, turn on debugging, and more.

Configuring Our Site

With Soketi now installed and configured, we can update our Laravel application to connect to our Soketi server.

By default, the config/broadcasting.php configuration file does not contain the additional options that we need when connecting to a Soketi server. The pusher configuration will need updating:

'connections' => [
    // ...

    'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY', 'app-key'),
        'secret' => env('PUSHER_APP_SECRET', 'app-secret'),
        'app_id' => env('PUSHER_APP_ID', 'app-id'),
        'options' => [
            'host' => env('PUSHER_HOST', ''),
            'port' => env('PUSHER_PORT', 6001),
            'scheme' => env('PUSHER_SCHEME', 'http'),
            'encrypted' => true,
            'useTLS' => env('PUSHER_SCHEME') === 'https',

We'll also need to update our .env file with the new configuration details:



By default, Soketi starts a server using app-key, app-id, and app-secret credentials. You can change these using Soekti environment variables.

Finally, you should change the PUSHER_HOST environment variable to the IP address of your Forge server. Your project should now be able to connect to the Soketi server.

Last updated 1 week ago.
Like this article? Let the author know and give them a clap!

Other articles you might like

August 8th 2022

Why don't you start writing tests?

See how easy it is to get started with automated testing in Laravel There are hundreds of articles...

Read article
February 4th 2022

How to find the slowest query in your application

Is your website slow? does it take ages to load? Are the users complaining that it's almost unusable...

Read article
June 30th 2022

Validating File Upload Arrays in Laravel

Let's say you have an HTML form with 3 file inputs named certificate[], and you want to make them al...

Read article

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.