What you need before starting
- A Linux server with SSH access and Node.js installed (use an LTS version).
- Your code in a repository and a
package.jsonwith astartscript. - A domain pointing to the server’s IP.
The steps, in short
- Secure the server: non-root user, SSH keys and a firewall open only on ports 22, 80 and 443.
- Clone the project and install dependencies with
npm ci --omit=dev. - Set the environment variables on the server (port, keys, database connection). Do not commit them to the repository.
- Keep the app alive with PM2 (
pm2 start app.jsandpm2 save) or a systemd service. - Put Nginx in front as a reverse proxy to your app’s port.
- Enable HTTPS with Let’s Encrypt (certbot).
- Automate deploys: a GitHub Actions workflow that connects over SSH, runs
git pull, installs and restarts.
Common mistakes
- Listening on a different port than the one Nginx points to; check that the ports match.
- Running
npm installwithNODE_ENVunset and ending up with dev dependencies in production. - Not handling uncaught errors: a single
throwcan take the process down. - Storing uploaded files inside the project and losing them on the next deploy.
How we help
We give you the free 30-minute diagnostic and leave your app running with automatic restarts, HTTPS, deploys from GitHub and alerts if something goes down.