ADMISSIONS OPEN
🔥 Admissions Open • Book Your FREE Digital Marketing Demo Class • Limited Demo Slots Available • 🚀 Start Your Digital Marketing Career Today • 💼 Practical Training + Career Guidance • 🎯 Reserve Your Seat Before Today's Slots Fill
Book FREE Demo

How to Host an Express.js API on Hostinger

Disclosure: some links on this page are affiliate links. If you buy through them, AdifySkills may earn a commission at no extra cost to you. We only recommend hosting we use ourselves.

Quick answer: To host an Express API on Hostinger, add a start script to package.json, make the server listen on process.env.PORT, move secrets to environment variables, push to GitHub, create a Node.js web app in hPanel, connect the repo, add variables, deploy and attach a subdomain like api.yourdomain.com with HTTPS. Add CORS, rate limiting, logging and database backups before going live.

Check today’s Hostinger price →

Your API deserves a stable home

Express is still one of the simplest ways to build a backend in Node.js: a few routes, some middleware, a database connection, and you have an API for your website, mobile app or internal tools. The tricky part has always been hosting it reliably without becoming a full-time server administrator.

With Hostinger's managed Node.js hosting, you can deploy an Express API from GitHub with environment variables, automatic redeploys and HTTPS. This guide shows how to host an Express API on Hostinger and make it production-ready.

Step 1: structure your Express project

A simple, deployable structure:

  • package.json with dependencies and scripts
  • server.js or src/index.js as the entry point
  • routes/ for route handlers
  • .env.example listing required variables (without values)

Scripts

  • "start": "node server.js"
  • Optional "build" if you use TypeScript (for example tsc), with "start": "node dist/server.js".

Port

The most important line in a deployable Express app:

const port = process.env.PORT || 3000; followed by app.listen(port).

Never hard-code the production port.

Host your API on Hostinger Cloud Startup

Recommended: Hostinger Cloud Startup. Daily or weekly backups, free SSL, 30-day money-back guarantee.

Get Hostinger Cloud Startup →Opens Hostinger’s official site. See today’s price before you decide.

Step 2: environment variables

Move everything sensitive or environment-specific into variables:

VariableExample use
NODE_ENVproduction
DATABASE_URLDatabase connection string
JWT_SECRETSigning tokens
ALLOWED_ORIGINFrontend domain for CORS
Third-party keysPayment, email, AI or map APIs

Load them with a library such as dotenv locally, and set them in hPanel for production.

Step 3: deploy

  1. Push to GitHub (keep .env out of the repo with .gitignore).
  2. In hPanel, add a new Node.js web app (labels may vary).
  3. Connect the repository and branch.
  4. Confirm install, build (if any) and start commands.
  5. Add environment variables.
  6. Deploy and check the logs.
  7. Visit a health route, such as /health, to confirm the API responds.

Step 4: connect a subdomain

Use a subdomain like api.yourdomain.com. Attach it to the app and confirm SSL is active. Update your frontend to call the new HTTPS URL.

âš  Open APIs get abused quickly

Bots scan the internet for open APIs. Without rate limiting, authentication and input validation, your API can be spammed, scraped or used to run up costs on paid third-party services you call. Add basic protections before you share the URL anywhere.

Step 5: make it production-ready

Security basics

  • Helmet or similar middleware for secure HTTP headers.
  • CORS limited to your real frontend domains.
  • Rate limiting on public endpoints, especially login and forms.
  • Input validation with a schema library.
  • Authentication with tokens or sessions where needed.
  • No stack traces in production error responses.

Reliability basics

  • A /health route for uptime monitors.
  • Structured logging so you can find errors in the logs.
  • Graceful error handling middleware.
  • Timeouts on calls to external services.

Data basics

  • Use a database created in hPanel (MySQL or MariaDB) or a managed external database.
  • Use connection pooling.
  • Back up the database regularly and test restores.

Not sure which plan fits your business? Send us a WhatsApp message and we will suggest the right plan for free.

Chat on WhatsApp

Connecting a frontend

A common setup: a React or Next.js frontend at app.yourdomain.com and the Express API at api.yourdomain.com, both on the same Hostinger plan. Set ALLOWED_ORIGIN to the frontend domain and configure the frontend's API base URL with an environment variable.

Performance tips

  • Cache expensive responses in memory or a cache layer.
  • Paginate large lists instead of returning everything.
  • Compress responses with compression middleware.
  • Index database columns used in filters and joins.
  • Keep middleware lean.

Scaling: when to move up

SignalNext step
Steady traffic, a few appsCloud Startup
Heavy background jobs or many persistent connectionsVPS
Need for Docker or system-level packagesVPS
Very high traffic across regionsDedicated cloud infrastructure
PlanIndia price*US price*WebsitesStorageBackupsBest for
Single₹69/mo
renews ₹289/mo
India only110 GB SSDWeeklyOne small site or portfolioGet Single
Premium₹139/mo
renews ₹449/mo
$2.49/mo
renews $10.99/mo
320 GB SSDWeeklyPersonal sites and side projectsGet Premium
Unlimited₹199/mo
renews ₹649/mo
$3.49/mo
renews $16.99/mo
Unlimited50 GB NVMeDailyMost business websitesGet Unlimited
Cloud Startup₹599/mo
renews ₹1,599/mo
$7.99/mo
renews $25.99/mo
Unlimited100 GB NVMeDaily + on-demandBusy stores, web apps, agenciesGet Cloud Startup

*Promotional prices on a 48-month term, checked on Hostinger's official site in November 2026 during a sale. Prices change often and renewal prices are higher. Indian prices exclude 18% GST. Always confirm the live price before you pay.

Common errors and fixes

ErrorLikely causeFix
App crashes on startHard-coded port or missing variableUse process.env.PORT, set variables
CORS error in browserOrigin not allowedAdd the frontend domain to CORS config
Database connection refusedWrong host or credentialsCheck DATABASE_URL and database access settings
502 or timeoutApp not listening, or slow upstreamCheck logs, add timeouts
Works locally, fails on deploydevDependencies used at runtimeMove packages to dependencies

Real-world uses for small businesses

  • A lead capture API that saves form submissions to a database and sends WhatsApp or email alerts.
  • A booking API for a clinic or salon.
  • An inventory or price lookup for a shop.
  • A webhook receiver for payment gateways or CRMs.
  • A backend for a simple mobile app.

All of these fit comfortably on managed Node.js hosting.

A minimal production-ready Express checklist

Before you announce your API, run through this list:

  • ✅ Listens on process.env.PORT
  • ✅ NODE_ENV=production set
  • ✅ All secrets in environment variables
  • ✅ Helmet (or equivalent) enabled
  • ✅ CORS limited to known domains
  • ✅ Rate limiting on public routes
  • ✅ Input validation on every write endpoint
  • ✅ Central error handler that hides stack traces
  • ✅ /health route and an uptime monitor
  • ✅ Database backups scheduled and tested
  • ✅ HTTPS subdomain connected
  • ✅ Logs checked after the first real traffic

Versioning your API

As soon as other apps depend on your API, changes can break them. A simple approach is to prefix routes with a version, such as /v1/leads. When you need breaking changes, add /v2/ routes and keep /v1/ working until every client has moved. Document the endpoints, even in a short README, so future you and your clients know what each one does.

Our view

AdifySkills runs its website on Hostinger and teaches automation and web development, including APIs and webhooks. For small businesses and freelancers, an Express API on managed hosting is the simplest way to add custom backend features without the overhead of managing servers.

Deploy your Express API today

Recommended: Hostinger Cloud Startup. Daily or weekly backups, free SSL, 30-day money-back guarantee.

Get Hostinger Cloud Startup →Opens Hostinger’s official site. See today’s price before you decide.

Conclusion

Hosting an Express API on Hostinger is mostly about preparation: a start script, process.env.PORT, environment variables and a clean repo. Deploy through hPanel, attach an HTTPS subdomain, then add security, logging and backups. For most small and medium APIs, Cloud Startup gives the resources and predictable pricing you need, with a VPS available when you outgrow it.

Frequently Asked Questions

Can I host an Express.js app on Hostinger?

Yes. Hostinger's managed Node.js hosting can deploy Express apps from GitHub or a ZIP upload.

What port should my Express app use on Hostinger?

Use the port provided by the environment through process.env.PORT, with a fallback for local development.

Can I use MySQL with my Express API on Hostinger?

Yes. Create a MySQL database in hPanel and connect to it using credentials stored in environment variables.

How do I keep my API secure?

Use HTTPS, restrict CORS, add rate limiting, validate inputs, require authentication where needed and hide error details in production.

Can I run a frontend and API on the same plan?

Yes. Many developers host a React or Next.js frontend and an Express API on the same Hostinger plan.

When should I move my API to a VPS?

When you need Docker, system-level packages, heavy background workers or many long-lived connections.

Ready to get your website on fast, reliable hosting?

  • Free SSL and free domain for the first year on most plans
  • Automatic backups
  • 24/7 support
  • 30-day money-back guarantee

Claim the Hostinger deal →Ask us on WhatsApp

About the author: Charanjeet Singh is the founder of AdifySkills, a digital marketing and web skills institute in Faridabad, India. He builds and manages WordPress sites, landing pages and automations for businesses. adifyskills.com itself runs on Hostinger.

Have a question about this?

Leave your details and our counselling team will get in touch.

Scroll to Top
Hostinger sale: fast hosting from a low monthly price See today's deal