Question

I can't log in after a period of inactivity

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


Submit an answer


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!

Sign In or Sign Up to Answer

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.

KFSys
Site Moderator
Site Moderator badge
March 9, 2025

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.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.