Skip to content

Instantly share code, notes, and snippets.

Last active March 5, 2024 17:34
Show Gist options
  • Save smoofit/dafa493aec8d41ea057370dbfde3f3fc to your computer and use it in GitHub Desktop.
Save smoofit/dafa493aec8d41ea057370dbfde3f3fc to your computer and use it in GitHub Desktop.
Howto install mosquitto with websockets

Install mosquitto with websockets

This is a guide how to install mosquitto on Ubuntu with websockets enabled.

It is more or less the same as explained in the article "Six Steps to install mosquitto 1.4.2 with websockets on debian whezy"


  1. mosquitto version 1.4.10 is used.
  2. libwebsockets-dev was installed using apt-get instead of building from source.

Install the dependencies

$ sudo apt-get update
$ sudo apt-get install build-essential python quilt python-setuptools python3
$ sudo apt-get install libssl-dev
$ sudo apt-get install cmake
$ sudo apt-get install libc-ares-dev
$ sudo apt-get install uuid-dev
$ sudo apt-get install daemon
$ sudo apt-get install libwebsockets-dev

Download mosquitto

$ cd Downloads/
$ wget
$ tar zxvf mosquitto-1.4.10.tar.gz
$ cd mosquitto-1.4.10/
$ sudo nano



Build mosquitto

$ make
$ sudo make install
$ sudo cp mosquitto.conf /etc/mosquitto

Configure ports for mosquitto

Add the following lines to /etc/mosquitto/mosquitto.conf in the "Default Listener" section:

port 1883
listener 9001
protocol websockets

Add user for mosquitto

$ sudo adduser mosquitto

Reeboot computer

$ reboot

Run mosquitto

$ mosquitto -c /etc/mosquitto/mosquitto.conf
Copy link

Hello All,
I have Successfully install Mqtt with Instruction from and running well.
but my mqtt server only listening on http protocol and I would like to use with websocket, and I follow Instruction Above
but my mqtt server won't start anymore with error Websockets support not available.
How to correct this issue

For Information I use
OS Ubuntu 16.04

Trying Clean installation of Ubuntu 16.04 and reinstall mosquitto with instruction above... now works fine for me.. thanks for tutorial

Copy link

It works!!! thank you!!

Copy link

It is working with
I installed it on a raspberry, but before I could build it I need to install cJSON

git clone
cd cJSON/
mkdir build
cd build/
cmake ..
make install

I hope this help if you get the error: cjson/cjson.h no such file or directory

Copy link

sudo yum install openssl-devel worked

it work for me centos7, mosquitto 1.6 (after allow firewall)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment