Debian 8 nginx 502 error

Hi there,

i’m new to mattermost and want to set it up for my company. I already follow the installing guid for Debian jessie, but at the last step of “setting up the nginx server” i got a 502 Error instead of page titles "Mattermost - Signup"
as i say i have follow exactly the guid with one exception: the ip-address.

what can i do?

thanks in advance

sorry for my bad english

Hi @Flix,

can you access Mattermost with localhost and port 8065 (Im asuming you’re using the default port)

hi @elias,

if i try to i got the following error
curl: (7) Failed to connect to localhost port 8065: connection refused

Then the problem is not NGINX but that your mattermost instance is not running.

can you cd to cd /opt/mattermost/bin and the run ./platform and see if it runs?

it seem that mattermost is running.
i got the following prompt after ./platform

root@mattermost:/opt/mattermost/bin# ./platform
[2016/08/10 08:52:49 CEST] [INFO] Loaded system translations for ‘en’ from ‘/opt/mattermost/i18n/en.json’
[2016/08/10 08:52:49 CEST] [INFO] Current version is 3.2.0 (3.2.0/Thu Jul 14 16:27:27 UTC 2016/ab52700aaa76a5623de23cd0156f5dbd9a24e264/none)
[2016/08/10 08:52:49 CEST] [INFO] Enterprise Enabled: false
[2016/08/10 08:52:49 CEST] [INFO] Current working directory is /opt/mattermost/bin
[2016/08/10 08:52:49 CEST] [INFO] Loaded config file from /opt/mattermost/config/config.json
[2016/08/10 08:52:49 CEST] [INFO] Server is initializing…
[2016/08/10 08:52:49 CEST] [INFO] Pinging sql master database
[2016/08/10 08:52:49 CEST] [INFO] Pinging sql replica-0 database
[2016/08/10 08:52:49 CEST] [DEBG] Deleting any unused pre-release features
[2016/08/10 08:52:49 CEST] [DEBG] Initializing user api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing team api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing channel api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing post api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing web socket api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing file api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing command api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing admin api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing general api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing oauth api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing webhook api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing preference api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing license api routes
[2016/08/10 08:52:49 CEST] [DEBG] Initializing emoji api routes
[2016/08/10 08:52:49 CEST] [DEBG] Parsing server templates at /opt/mattermost/templates/
[2016/08/10 08:52:49 CEST] [DEBG] Initializing web routes
[2016/08/10 08:52:49 CEST] [DEBG] Using client directory at /opt/mattermost/webapp/dist/
[2016/08/10 08:52:49 CEST] [INFO] Starting Server…
[2016/08/10 08:52:49 CEST] [INFO] Server is listening on :8065
[2016/08/10 08:52:49 CEST] [INFO] RateLimiter is enabled

thats why i’m so confused about the error 502 at nginx

can you share your nginx config?

for sure
here is my nginx.conf

i hope you can find the problem

kind regards
Flix

I don’t see the mattermost configuration on that file, can you make sure you follow the steps here: https://docs.mattermost.com/install/prod-debian.html#set-up-nginx-server

i have a config for mattermost in the site-available folder of nginx
mattermost conf

or should that in the nginx.conf? should it be, than the install guide is not clearly at this point.

Thats completely fine to have another config file in NGINX for the available sites.

As far as I can tell it all seems good.

one last question, what happens if from within the same network you try to access http://192.168.40.26:8065 ? are you able to load Mattermost?

Hello @elias,

sry for the long break, over the weekend i didnt have the access to the server.

if i try to access via curl http://192.168.40.26:8065
i got the following error:
curl: (7) Failed to connect to 192.168.40.26 port 8065: Verbindungsaufbau abgelehnt

can it be a problem if the database-server got the same ip as the mattermost-server? both are on the same maschine.

kind regards
flix

Nop its not a problem of the database being on the same or other server, as you can see your console after entering ./platform

can I ask a dumb question? did you ensure mattermost is running while executing curl?

i’m 100% sure that mattermost is running while i executing curl.

to prove that i will show you the last comands and the prompt
root@mattermost:~# service mattermost status ● mattermost.service - Mattermost is an open source, self-hosted Slack-alternative Loaded: loaded (/etc/systemd/system/mattermost.service; enabled) Active: activating (auto-restart) since Mo 2016-08-15 15:08:23 CEST; 6s ago Process: 10675 ExecStart=/opt/mattermost/bin/platform (code=exited, status=0/SUCCESS) Main PID: 10675 (code=exited, status=0/SUCCESS) root@mattermost:~# cd /opt/mattermost/bin/ root@mattermost:/opt/mattermost/bin# ls platform root@mattermost:/opt/mattermost/bin# ./platform [2016/08/15 15:09:14 CEST] [INFO] Loaded system translations for 'en' from '/opt/mattermost/i18n/en.json' [2016/08/15 15:09:14 CEST] [INFO] Current version is 3.2.0 (3.2.0/Thu Jul 14 16:27:27 UTC 2016/ab52700aaa76a5623de23cd0156f5dbd9a24e264/none) [2016/08/15 15:09:14 CEST] [INFO] Enterprise Enabled: false [2016/08/15 15:09:14 CEST] [INFO] Current working directory is /opt/mattermost/bin [2016/08/15 15:09:14 CEST] [INFO] Loaded config file from /opt/mattermost/config/config.json [2016/08/15 15:09:14 CEST] [INFO] Server is initializing... [2016/08/15 15:09:14 CEST] [INFO] Pinging sql master database [2016/08/15 15:09:14 CEST] [INFO] Pinging sql replica-0 database [2016/08/15 15:09:14 CEST] [DEBG] Deleting any unused pre-release features [2016/08/15 15:09:14 CEST] [DEBG] Initializing user api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing team api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing channel api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing post api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing web socket api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing file api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing command api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing admin api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing general api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing oauth api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing webhook api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing preference api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing license api routes [2016/08/15 15:09:14 CEST] [DEBG] Initializing emoji api routes [2016/08/15 15:09:14 CEST] [DEBG] Parsing server templates at /opt/mattermost/templates/ [2016/08/15 15:09:14 CEST] [DEBG] Initializing web routes [2016/08/15 15:09:14 CEST] [DEBG] Using client directory at /opt/mattermost/webapp/dist/ [2016/08/15 15:09:14 CEST] [INFO] Starting Server... [2016/08/15 15:09:14 CEST] [INFO] Server is listening on :8065 [2016/08/15 15:09:14 CEST] [INFO] RateLimiter is enabled [2016/08/15 15:09:14 CEST] [DEBG] Checking for security update from Mattermost ^X^Croot@mattermost:/opt/mattermost/bin# service mattermost start root@mattermost:/opt/mattermost/bin# curl http://192.168.40.26:8065 curl: (7) Failed to connect to 192.168.40.26 port 8065: Verbindungsaufbau abgelehnt

i also already try to reinstall it and got the same issue

would it be helpful if i share all my config that i made during the installation of mattermost?

kind regards
Flix

Maybe i’ll be best if you join our Developers Channel so we can have a little bit more interaction so we can help you figure this one out.

Hi,

did you found a solution? I’m currently struggling with the same issue…

Thanks in advance :slight_smile:

Dave

Well I think I could have figured this one out. I’m not using the script but the systemd unit and i set up everything on the same machine, so I’m using localhost or 127.0.0.1 instead of the IPs mentioned in the tutorial.

Assuming you have an additional user (if not create one, add him to the sudo group and add him to the mattermost group) in your sudo group and you are not running as root:

  1. Make sure you run the /.platform (for the first testing) as user mattermost and not as root.

  2. If you did run the platform as root, stop the service and delete the log file.
    sudo systemctl stop mattermost
    sudo rm /opt/mattermost/logs/mattermost.log
    (see GitHub)

  3. Give the mattermost user and group their permissions back.
    sudo chown -R mattermost:mattermost /opt/mattermost
    sudo chmod -R g+w /opt/mattermost

  4. If you were using the script, just disable/delete it.

  5. If not already done, setup the systemd unit as described in the docs.
    sudo touch /etc/systemd/system/mattermost.service
    sudo vi /etc/systemd/system/mattermost.service
    Copy the following lines into /etc/systemd/system/mattermost.service

[Unit]
Description=Mattermost is an open source, self-hosted Slack-alternative
After=syslog.target network.target

[Service]
Type=simple
User=mattermost
Group=mattermost
ExecStart=/opt/mattermost/bin/platform
PrivateTmp=yes
WorkingDirectory=/opt/mattermost
Restart=always
RestartSec=30
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target
(just copied this from the docs)

  1. sudo systemctl daemon-reload

  2. sudo systemctl enable mattermost

  3. sudo systemctl start mattermost

  4. stop the nginx service
    sudo systemctl stop nginx

  5. edit the Mattermost nginx config that it fits your needs; here is mine (with already set up SSL). Please replace YOURDOMAIN with your domain:

server {
listen 80;
server_name YOURDOMAIN;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name YOURDOMAIN;

ssl on;
ssl_certificate /etc/letsencrypt/live/YOURDOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOURDOMAIN/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ‘EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH’;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

location / {
gzip off;
proxy_set_header X-Forwarded-Ssl on;
client_max_body_size 50M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://localhost:8065;
}
}

  1. Start/restart the nginx service and point your browser to your domain.

Hi Dave3o3,

thank for your post. i didn´t find any solution for this problem thats why i switch to ubuntu an setup mattermost on there.
So i can not try this out, but maybe your post ost can help someone else with the same problem in the future.

kind regards
Flix

Awesome thx @Dave3o3 hopefully this will help other folks.