How-toUpdated 30 October 20264 min read

Deploy a Node.js and Express API with PostgreSQL in India

Short answer

Commit your lockfile, give package.json a start script, listen on process.env.PORT, add a /healthz route and read the database from DATABASE_URL. Push to Nexovia or upload a zip: it builds on a separate server, checks the code and packages, starts the new version beside the old one and switches only when the health route answers. A measured Express API went live in 29 seconds.

1. Prepare package.json

2. Listen on the right port and add a health route

Use app.listen(process.env.PORT || 3000), never a fixed port in production. Add app.get("/healthz", (req, res) => res.send("ok")); a release only goes live when this answers.

3. Connect PostgreSQL

Request a managed database for the app; the connection string arrives as DATABASE_URL. With Prisma, Knex or Drizzle, keep migrations in the repository and set the migrate command so it runs on every release.

4. Keep keys out of the code

Payment, SMS and AI keys go into project variables, stored in a vault and given to the app at start. A key written into the code stops the release, with the file and line shown.

Questions

Where can I host a Node.js API in India?

On Nexovia, a Node.js API with a managed PostgreSQL database runs on servers in India from ₹499 a month, with HTTPS on your domain and a security check on every release.

Do I need Docker to deploy Express?

No. Nexovia builds Node.js projects from package.json. If you have your own Dockerfile, it is used instead.

How do I run database migrations on deploy?

Set the migrate command, for example npx prisma migrate deploy, in the project settings; it runs before the new version takes traffic.

Quick Connect

Quick Connect

Leave your number and our team will call you back.

See our privacy notice.