Hi I recently installed an app on a droplet with react and express with a mysql database. Everything is going fine except when no one uses the site, after some downtime no one can log in. If I go to the console and do “pm2 restart index” the backend restarts and everything works fine. My question is, do I have to configure something in nginx or in express to keep the site always online?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya,
The website should be working without a need for a restart.|
When that happens again, check your nginx and pm2 logs. Also, check the logs of the Droplet. It’s possible the Droplet runs out of memory and kills the process keeping the website up.
Hi,
First, look at your PM2 configuration, use pm2 show index and ensure it’s set to restart on failures (–restart-delay can help prevent rapid restarts).
Also, check if the --watch flag is enabled, as it can help restart the process when files change. If your server goes down due to inactivity, you might want to check if there’s any resource throttling happening on your droplet (use htop or free -m to monitor RAM usage). For Express, you could try keeping a persistent connection by sending periodic keep-alive requests, or use pm2 keep-alive settings.
If Nginx is involved, make sure your proxy settings aren’t timing out connections (proxy_read_timeout and proxy_connect_timeout values can be increased). If the issue persists, look at syslog or pm2 logs to find what’s actually killing the process.