[SOLVED] Mattermost + hubot + docker



I want play with hubot-mattermost on my Mac, so I installed Mattermost with Docker (with the guide on the official site). I launch my container with
“docker run --name mattermost-preview -d --publish 8065:8065 mattermost/mattermost-preview”.

In Mattermost, I configured my outgoing webhook with the callback URL “”.

With this configuration, when I write something in my target channel, I have “Event POST failed, err=Post address forbidden” in Mattermost logs on my container.

So I configured “Allow untrusted internal connections to:” in Mattermost with “”. Now, I have no error in Mattermost logs.

So I can launch hubot with this configuration :
and this command : bin/hubot --adapter mattermost

But I have this error in hubot logs :
[Tue May 01 2018 16:27:33 GMT+0200 (CEST)] ERROR Error: listen EADDRINUSE
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1367:14)
at listenInCluster (net.js:1408:12)
at doListen (net.js:1517:7)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3

I think it’s because the port 8065 is already used by Mattermost server (exposed in my docker container).

I don’t know how I should configure my Mattermost and my hubot properly.

Can someone help me please ?
And sorry for my English.

Thanks all.


I don’t use mattermost-preview nor Hubot, but if you run a container using the --publish 8065:8065 option then your application (here the mattermost server) will bind the port 8065 on your host.

I’m not sure but I think your EXPRESS_PORT should be different than your Mattermost port. I guess that you need to choose another port for EXPRESS_PORT and change the callback URL of your Mattermost outgoing webhook with this port.


Hi, thanks for your reply. Yes, that’s I saw, the hubot start on the port 8081 for me now, and the problem is I can’t start hubot on the same port as exposed by docker. Finally, I installed hubot in the mattermost container. The problem is solved. Thank you pichouk.


Hi Antoine, Can you explain how you did it? I have the same problem, I can’t get Hubot to work/connect with Mattermost 4.9.0 on my docker.

Thank you very much!


Hi Fabianski-tr,

I created a new Docker image by creating this Dockerfile :

FROM mattermost/mattermost-preview:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install curl -y
RUN apt-get install sudo -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN npm install -g yo generator-hubot && useradd hubot -m -s /bin/sh

USER hubot
WORKDIR /home/hubot
RUN echo no | yo hubot --owner=“Name mail@address.com” --name=“webhook-hubot” --description=“Hubot for mattermost webhooks” --adapter=mattermost &&
sed -i /heroku/d ./external-scripts.json && sed -i ‘/dependencies/a “coffee-script”: “^1.12.6”,’ ./package.json

USER root
ADD docker-entry.sh .

RUN chmod +x ./docker-entry.sh
ENTRYPOINT ./docker-entry.sh

The docker-entry.sh file is this file : https://github.com/mattermost/mattermost-docker-preview/blob/master/docker-entry.sh

Then launch your container, connect to it, and use a port different of 8065 to launch your hubot instance (with the EXPRESS_PORT environment variable). Configure the others hubot environment variable. Finally, you can configure your outgoing webhook in Mattermost with this callback url : http://localhost:{EXPRESS_PORT}/{MATTERMOST_ENDPOINT}

Good luck.


It returns authentication errors all the time:

"{“level”: “info”, “ts”:1525859555.876387, “caller”: “api4/context.go:127”, “msg”: "Invalid session err=GetSession: Invalid session token=r7ajssnci7f59fg9eybi8te9ma, err=<, "}

Am I missing any other settings?
I realize this:

export MATTERMOST_ENDPOINT=/hubot/incoming
export EXPRESS_PORT=8080
./bin/hubot -a mattermost


Check your tokens in MATTERMOST_INCOME_URL and MATTERMOST_TOKEN variables. You should get them from Mattermost webhook configuration.

I have the same configuration without MATTERMOST_SELFSIGNED_CERT. I didn’t set it. Maybe you can try without this variable set.


If I have configured the parameter EXPRESS_PORT=8080.

Then in the configuration in the Outgoing Webhook (Mattermost) is the following, right?


Yes, that’s my case (with port 8081). You can try another port, maybe your port 8080 is already used.


And there is no need for any more configuration or user creation in a different way? I don’t understand if everything is the same as you indicated because the bot doesn’t answer. :frowning:


No sorry, I don’t understand why the bot doesn’t answer.


¿You create userbot with Matterbot invite link?

My steps are:

  1. Run container with port 8065
  2. Create a new user admin
  3. Create a normal user for Bot
  4. Enable Webhooks (Incoming and Outgoing) on Custom Integration
  5. Configure the webhooks with the settings I have indicated above
  6. Export config on container and run Hubot with mattermost adapter

Am I missing something?


No sorry. I did the same thing. I have no idea to help you at this point.