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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.