Error - Opening handshake timed out

My bot was running okay locally until recently it sometimes raises the timed out error when I tried re-running the code. The error goes like this:
.../node_modules/ws/lib/websocket.js:856
      abortHandshake(websocket, req, 'Opening handshake has timed out');
      ^

Error: Opening handshake has timed out

Sometimes all I need to do is just restart (re-running the command) several times until it works normal again. Why does this happen and how I can fix it?
Was this page helpful?