Arsal • Location • Starter

Technical Review: Hostcry Engineering Team

How to Host a Node.js Application and Stay in Control

AI Summary
Hosting a Node.js application means keeping the Node.js process running on a server, then putting a domain and HTTPS in front of it. Choose a managed Node.js plan for a normal API or site, and a VPS when the app needs workers, custom ports, Docker, or heavy WebSocket traffic. Prepare the project first: set a startup file, read process.env.PORT, keep secrets out of Git, and install dependencies on the server. Upload the app, start it, point the domain at the host, and use the application log if the first visit fails. HostCry offers Node.js hosting in Pakistan, separate from its shared hosting plans, so compare the current plan limits before you deploy.

A Node.js app that answers only on localhost is invisible to everyone else. How to host a Node.js application comes down to a server that keeps the Node.js process running, with a domain and HTTPS in front of it. Do the work in four moves: pick a hosting model that matches how the app behaves, prepare the project, start the process, and point the domain at it. What follows is the first deploy of one application, not a cluster build.

What Has to Be in Place Before a Node.js App Can Go Live

Hosting a Node.js application means a supported Node.js runtime is executing your code as a long-running process, and a public hostname reaches that process over HTTPS. Node.js is the runtime that executes JavaScript outside the browser. A host that only stores files can publish a static site. It cannot keep a server process alive.

Five parts have to exist together:

  • A Node.js version your project actually runs on

  • The application files, with production dependencies installed on the server

  • A process that continues after you disconnect

  • A public hostname

  • HTTPS terminated in front of the process

A finished React, Vue, or Angular build is a different deployment. It does not need a Node.js process. Next.js does, when you run its Node server instead of a static export.

Shared Hosting, a VPS, or a Managed Platform: Which Fits Your App

Match the plan to the way the app runs, before checkout.


Shared cPanel with Node.js

Self-managed VPS

Managed Node.js plan

Who starts the process

Panel app server, often Passenger

You, with PM2 or systemd

The platform

Public ports

Assigned for you

You choose, then proxy

Assigned for you

Always-on workers

Poor fit

You can run them

Only if processes stay awake

Who patches the OS

The host

You

The host

Apps that fit a control-panel or managed Node host

Express, Fastify, and a small Next.js server fit a panel or managed plan. Confirm Node.js is on that plan. HostCry’s shared hosting specification lists Passenger applications as 0 on Starter and 4 on Professional and Advance. The separate Node.js product lists PM2, SSH, and Git. Shared Starter does not include that stack.

Apps that need a VPS

Choose a VPS with root access for queue workers, custom ports, Docker, or many simultaneous WebSocket connections.

Where a managed platform fits

Use a managed platform when a Git push should build and restart the app. Some free tiers pause until the next request, so the first hit is slow. Visitors in Pakistan or the UAE should ask which data-centre region the plan uses. UAE teams can compare plans on HostCry’s UAE hosting page.

Make the App Production-Ready Before You Upload It

Fix the project before the first upload. A correct host still fails when the startup file never listens, or when dependencies were built on your laptop.

  • package.json lists the dependencies and a start script.

  • The startup file is the module that creates the server. For an app made with the Express generator, that file is often bin/www, not app.js.

  • The app reads process.env.PORT and still runs locally if the variable is missing.

  • Set engines to a Node.js version the host offers on deploy day. LTS lines change.

  • Secrets live in environment variables. Keep .env out of Git and out of any public folder.

  • Leave node_modules off the upload. Install on the server with npm ci when a lockfile exists. An ordinary SSH npm install often hits a different Node.js binary, so modules land in the wrong place.

  • Set NODE_ENV=production on the live process.

Node.js exposes environment variables on process.env. Use this pattern:

const port = process.env.PORT || 3000;

server.listen(port);

Call listen() once. Passenger’s reverse port binding ignores that port number and binds its own socket to the first http.Server that listens. Skip listen() and Passenger times out. Call it twice and Passenger refuses the app. Hosts that set PORT still need the variable.

Deploy the Application and Start the Node.js Process

How you host a Node.js application depends on who is allowed to start the process. Follow the panel path when the host provides an app manager. Follow the VPS path only when you have root and you chose that model earlier.

Deploy with a control-panel or managed Node.js host

  1. Create the application in the host’s Node.js manager.

  2. Set the Node.js version, the application root (the folder that contains package.json), the public URL, and the startup file.

  3. Upload with Git or SFTP. Do not include node_modules.

  4. Install dependencies from the application screen.

  5. Enter environment variables in the panel, not in a file under the public folder.

  6. Restart the application, then open its URL.

Use the installer on the application screen. cPanel’s Node.js install document is written for server administrators. It shows package lists and Apache includes that a hosting customer should not edit, including httpd.conf.

HostCry’s Node.js page lists PM2, SSH, and Git as plan tools. On that product, use those tools. Do not add a second web server in front of a plan that already starts the process.


Deploy on a VPS when you need root access

  1. Install the Node.js LTS named in engines.

  2. Run the app as a user that is not root.

  3. Start it under PM2 or a systemd service, and enable start on boot. A process started in an SSH window dies when you log out.

  4. Put Nginx or Apache in front of Node.js.

  5. Proxy to 127.0.0.1 and the port the app reads from the environment. Leave the Node process off the public internet.

  6. Issue the certificate on the proxy. Operating-system updates, backups, and the firewall remain your job.

Connect Your Domain and Serve the App Over HTTPS

DNS can still point at the old host after the process is healthy. Move it in one of two ways.

Change

Use it when

Set the domain’s nameservers to the host

The host should manage every DNS record

Add an A record, or a CNAME on a subdomain

DNS stays at the registrar and only this hostname should move

Update the root name and www. Updating one of them leaves the other on the old target.

Each record follows its TTL. Until that timer expires, some resolvers still return the old address. The registrar’s DNS help shows the TTL for that zone.

Place the certificate on the host’s web server. On a VPS, the proxy is what visitors connect to.

A .com, .pk, or .ae name does not change the Node.js setup. The extension is a registration choice.

Registering the domain where you host the app avoids a nameserver hand-off between two logins. HostCry registers domains and sells hosting.

Confirm the App Is Running and Fix a Failed First Launch

Finish only when the public URL returns your application, the startup filename matches exactly, the panel shows the process running, and the log is clear of module and syntax errors.

What you see

What it usually means

What to do

502 or a connection error

The process is down, or it is not listening where the proxy expects

Read the application log, confirm the port variable, restart

Cannot find module

Dependencies were installed with the wrong Node.js, or node_modules came from your laptop

Reinstall in the app environment and restart

A code change never appears

The previous process is still in memory

Restart after every upload

An environment value is missing

The running process never received it

Set it in the panel or the service, then restart

On a shared account, those four checks are the repair. Apache configuration sits outside the account. If you are on HostCry and the log still shows a startup error after a clean reinstall, contact support with that log. No response time is promised here.

Resource Limits That Break Node.js Apps, and When to Move

After a clean startup, a later failure is sometimes the plan. Move up, or move to a VPS, when you see any of these:

  • The process is killed because it ran out of memory

  • The account repeatedly hits its CPU cap or its entry-process cap

  • Work must continue while nobody is requesting the site

  • WebSocket clients drop as soon as more than a handful connect

On CloudLinux, CPU, physical memory, entry processes, and I/O are capped per account. CloudLinux’s limits documentation describes those controls. The figures for your account are on its resource screen.

Passenger can shut an idle process down to save memory. Its Nginx reference sets passenger_pool_idle_time to 300 seconds by default, and a shared host may set another value. A setInterval loop stops when that process stops. Use the host’s cron for a timed HTTP call, and a VPS for a worker that must stay up.

What to Confirm With a Host Before You Pay

Ask these questions before you pay:

  • Which Node.js versions can this plan run today?

  • Is Node.js included, or is this plan only a VPS?

  • Who starts the process: a panel, or you over SSH?

  • Do backups include the application files?

  • Which data-centre region serves visitors in Pakistan or the UAE?

  • How do you reach a person when the app returns 502?

HostCry has offered hosting and domain registration since 2017, in Pakistan, the UAE, and other countries. Read the Node.js hosting page for current versions, PM2, and plan limits. On the day this was checked, that page listed Node.js 18, 20, 22, and 24. Check it again before you order.

Check the Plan Against the Process

Pick the plan that can keep this process alive, then treat the first application log as the acceptance test. Compare the Node.js hosting plans linked above with your Node.js version and the way the app runs. If that log still shows a failure, write to HostCry at [email protected] or on the WhatsApp number published on the site, +92 313 5638173.

Got questions?

Frequently Asked Questions

Quick answers about this article.

Yes, once the host’s process is running. Closing the laptop stops only the development server on that machine. The hosted app keeps answering while the plan keeps that process up.

Read the live page and note the billing term. HostCry’s Node.js hosting plans showed Starter at Rs 1,499 per month on a 12-month total of Rs 17,998, and the UAE page showed Node.js from AED 30 per month, when this was checked. Renewal can differ, and a VPS also costs patching time.

Yes, when the account includes both PHP and a Node.js runtime, and the resource cap covers both. Use a separate domain or subdomain for the app. Extra disk space does not add a Node.js runtime to a PHP-only plan.

No. SFTP or a zip file is enough when the host accepts it. HostCry’s Node.js page lists Git integration and does not require a GitHub account. Leave node_modules out of the repo and out of the archive.

Move the app onto a version that host publishes, or pick a host that publishes the version in engines. A newer Node.js binary does not mean older code will run unchanged. Test that exact version before you change DNS.

On many shared accounts, only MySQL or MariaDB is included. HostCry’s Node.js page lists MySQL, MongoDB, PostgreSQL, and Redis, and the engine can still depend on the plan. Confirm it before you code the client. Installing the engine yourself belongs on a VPS.

Only inside that plan’s application limit. HostCry’s Node.js page listed 1 application on Starter, 5 on Professional, and unlimited on Advance, subject to resources, when this article was checked. Other hosts publish a different count. Read the live plan before you promise a client a second app.

Yes, when the host gives you an application URL or a temporary hostname. Open it and confirm the process starts. Attach the real domain after that address returns the app, so DNS is not pointed at a crash.