Deploying a Node.js API to production — Railway and Render
production checklist, NODE_ENV production, process managers, health check endpoint, zero-downtime deploys, Railway deployment, Render deployment, build command, start command
Deploying a Node.js API to Production
Modern PaaS platforms eliminate most server management overhead. Railway and Render both support Node.js with automatic deploys on git push, managed PostgreSQL, and environment variable configuration.
Pre-Deployment Checklist
Set NODE_ENV=production — disables stack traces in error responses, enables Express performance optimizations. Ensure your package.json has a start script. Move devDependencies correctly so nodemon is not in dependencies.
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}Health Check Endpoint
// Add before all routes
app.get('/health', (req, res) => {
res.json({
status: 'ok',
uptime: process.uptime(),
timestamp: new Date().toISOString()
});
});Deploying to Railway
Install the Railway CLI: npm install -g @railway/cli. Run railway login, then railway init in your project. Push with railway up or connect your GitHub repo for automatic deploys. Add environment variables in the Railway dashboard under Variables. Provision a PostgreSQL plugin and Railway sets DATABASE_URL automatically.
For Render: push to GitHub, create a new Web Service in the Render dashboard, set Build Command to npm install and Start Command to npm start, add environment variables in the Environment tab.
