Sudden 502 error

I have the same issue on my localhost environment.
The rocketchat does not start after reboot, status is always failure “rocketchat.service: Failed with result ‘exit-code’.” Active: failed (Result: exit-code) since Sat 2020-09-19 19:59:26 EEST; 12min ago
Process: 551 ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js (code=exited, status=1/FAILURE)

19 19:59:26 debian rocketchat[551]: at Object.onceWrapper (events.js:300:26)
19 19:59:26 debian rocketchat[551]: at Socket.emit (events.js:210:5)
19 19:59:26 debian rocketchat[551]: at emitErrorNT (internal/streams/destroy.js:92:8)
19 19:59:26 debian rocketchat[551]: at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
19 19:59:26 debian rocketchat[551]: at processTicksAndRejections (internal/process/task_queues.js:8
19 19:59:26 debian rocketchat[551]: name: ‘MongoNetworkError’,
19 19:59:26 debian rocketchat[551]: [Symbol(mongoErrorContextSymbol)]: {}

But when I start rocketchat, “sudo systemctl start rocketchat” it starts to work.

So every time when I launch my virtual machine, everything else, like mongodb etc works but the rocketchat does not start, and to fix it it just needs “sudo systemctl start rocketchat”.

What should I do to fix this ?

  • mongod --version db version v4.4.1
  • npm --version6.14.8
  • rocket chat version 3.6.1
  • node js version v12.14.0

Replying to my self
I was able to fix this with a dirty fix:
put to crontab “@reboot sleep 20 && /etc/startrockechat.sh”
and put in that script “sudo systemctl start rocketchat”

Not any kind of good fix but for some reason it needs to wait something before the start gets succeed. If I put it without delay, the rockechat service on my debian will stay in a fail state.