I got a Nodejs project with was hosted in Digital Ocean and I keep it running using Forever script. But I realized that there will be some error after a period of time which causing the site down. It's not just happened once but few times already, below is the Forever log:
Error: Connection lost: The server closed the connection.
at Protocol.end (/var/www/menu/node_modules/mysql/lib/protocol/Protocol.js:109:13)
at Socket.<anonymous> (/var/www/menu/node_modules/mysql/lib/Connection.js:109:28)
at emitNone (events.js:72:20)
at Socket.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at nextTickCallbackWith2Args (node.js:441:9)
at process._tickCallback (node.js:355:17)
error: Forever detected script exited with code: 1
error: Script restart attempt #178
Listening on xxx.xxx.xxx.xxx, server_port 80
events.js:141
throw er; // Unhandled 'error' event
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
--------------------
at Protocol._enqueue (/var/www/menu/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/var/www/menu/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/var/www/menu/node_modules/mysql/lib/Connection.js:130:18)
at Connection._implyConnect (/var/www/menu/node_modules/mysql/lib/Connection.js:461:10)
at Connection.query (/var/www/menu/node_modules/mysql/lib/Connection.js:206:8)
at Object.<anonymous> (/var/www/menu/config/db.js:14:12)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
error: Forever detected script exited with code: 1
I'm not sure why this is happening as the log did not stated which line was causing error, and it seems like Forever had try to restart the script but it failed. But once I SSH into my server and start it again then it's working fine already. Anyone able to help? Thanks.