May 16, 2018

How to run a local offline development Pusher server.

In this article, I will go through how I setup a local Pusher websocket server on my local machine, this is something that's useful for getting offline support or save Pusher requests.

So I had 30 minutes before I had to board my 11 hours flight from Tokyo to Copenhagen. I had to work on a new websocket based functionality that I was building at the moment that was using Pusher. Not being able to access the internet and Pusher’s servers would make it difficult to work on this new feature. So I started to look into if Pusher had a local development server available so that I could use it offline.

After a couple of quick google searches, I found that there is a project called [pusher-fake] and that someone built a [Dockerfile] for this project. It is not released or maintained by Pusher themselves but it seems to have all the functionality which is just what I was looking for.

I needed a couple of customizations so I quickly built my own version of the image and created a basic proof of concept to see if I could get this working. After creating the docker image I created a quick PHP script and a simple JavaScript frontend client that is listening for messages from the PHP script. The PHP script is (located [here]) and the frontend client is (located [here]) if you would like to check it out.

The backend PHP script sends messages to the local Pusher server which then broadcasts it to all the frontend clients that are connected to the Pusher local dev server. Every time the frontend client receives a message it changes the background color and should look something like [this].

To run the demo application yourself simply follow these 4 steps:

git clone
cd pusher-local-dev-server
docker-compose up
open index.html (or double-click the index.html file to open it in your browser)

That’s it for this time, setting up a local dev Pusher server is great if you are on a limited plan and do not want to waste requests on your Pusher account while developing applications on your local machine. It’s also useful if you like me need offline support for your application that is using Pusher.

Until next time, have a good one!

Don’t forget to check out the full repository here:

Oliver Lundquist

Born in 🇸🇪, resident in 🇯🇵 for 13+ yrs, husband and father of a daughter and son, web developer since 2009.

Read more about me
•• Instagram (@olibalundo)