502 Bad Gateway

Description

I install Rocket.Chat with manual installation on Ubuntu following this tutorial. https://rocket.chat/docs/installation/manual-installation/ubuntu/

I am using nginx as the reverse proxy. The service is running, but there is no port 3000 opened at the network. I check it with netstat -plnt

The nginx configuration copied from rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/ with some modification.

When i open the browser, the nginx response Bad Gateway.

Is there any configurations that I missed ?

Thanks,

Server Setup Information

  • Version of Rocket.Chat Server: 2.4.0
  • Operating System: Ubuntu
  • Deployment Method: Tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog: none
  • NodeJS Version: v8.17.0
  • MongoDB Version: v4.0.14
  • Proxy: nginx
  • Firewalls involved: none

Any additional Information

rocketchat nginx access log
2019/12/31 03:00:12 [error] 31520#31520: *22 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: domain.ltd, request: “GET /serviceworker.js HTTP/1.1”, upstream: “http://127.0.0.1:3000/serviceworker.js”, host: “domain.ltd”

Hello semplon.
To figure out the cause of the problem, I suggest to try to manually start rocketchat from the command line with the command : ** ```
/usr/local/bin/node /opt/Rocket.Chat/main.js

Before executing the command, environment variables should be set. This can be done using the commands below : ** ```
export MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01
export  MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 
export  ROOT_URL=http://localhost:3000/
export PORT=3000
```**
Please would you mind trying it and letting us the result?

i got this error :

/opt/Rocket.Chat/programs/server/node_modules/fibers/fibers.js:90
                                    return fn.apply(this, arguments);
                                              ^

Error: Must pass options.rootUrl or set ROOT_URL in the server environment
at Object.Meteor.absoluteUrl (packages/meteor.js:1378:11)
at runWebAppServer (packages/webapp/webapp_server.js:771:18)
at packages/webapp/webapp_server.js:1178:1
at webapp_server.js (packages/webapp/webapp_server.js:1178:16)
at fileEvaluate (packages/modules-runtime.js:336:7)
at Module.require (packages/modules-runtime.js:238:14)
at require (packages/modules-runtime.js:258:21)
at /opt/Rocket.Chat/programs/server/packages/webapp.js:1610:15
at /opt/Rocket.Chat/programs/server/packages/webapp.js:1619:3
at /opt/Rocket.Chat/programs/server/boot.js:398:38
at Array.forEach (<anonymous>)
at /opt/Rocket.Chat/programs/server/boot.js:226:21
at /opt/Rocket.Chat/programs/server/boot.js:461:7
at Function.run (/opt/Rocket.Chat/programs/server/profile.js:280:14)
at /opt/Rocket.Chat/programs/server/boot.js:460:13
EasyRSA-3.0.4.tgz: command not found
EasyRSA-3.0.4.tgz: command not found

Please as the error message request, use the export commands to set environment variables.
Clearly do execute this commands:

export MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01
export  MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 
export  ROOT_URL=http://localhost:3000/
export PORT=3000

/usr/local/bin/node /opt/Rocket.Chat/main.js

@askoday I’m trying to update rocket chat manually using this documentation. (https://rocket.chat/docs/installation/updating/) but when I update rocket chat and try to access it shows 502 error.

I follow your above instructions. first I set environment variables using
export MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 export MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 export ROOT_URL=http://localhost:3000/ export PORT=3000

and then run this command (/usr/local/bin/node /opt/Rocket.Chat/main.js)

but I got error. please check the attached screenshot. and suggest me what can I do to resolve this issue.

Many thanks.

I’m having the same problem today - on an existing installation. How did you manage to fix it?

We had the same issue this morning and running the above commands does get the server running but unless I leave that putty window open the RC server returns to 502 Bad Gateway.

So it seems this is a temp solution?