Our cPanel hosting runs on CloudLinux, which lets you host Node.js and Python apps alongside your normal website. You choose the language version, cPanel creates an isolated environment for your app, and the web server starts it automatically when someone visits.

This suits small to medium apps such as an Express API, a Next.js or Nuxt site running in Node, or a Flask or Django project. For apps that need background workers, WebSockets, custom ports or more resources, a VPS is a better fit. See Install Node.js on your VPS.

Before you start

  • Decide on the address the app will run at, for example your main domain, a subdomain such as app.yourdomain.co.nz (see Create a subdomain in cPanel), or a path such as yourdomain.co.nz/api.
  • Upload your app's code to a folder outside public_html, for example /home/yourusername/myapp. Don't upload node_modules or a Python virtual environment, because they're created on the server. See Upload your website with File Manager or FileZilla.

Set up a Node.js app

  1. Log in to cPanel from your service page under Services → My Services (https://www.hooplahosting.co.nz/client/clientarea.php?action=services).
  2. Open Setup Node.js App (type Node in the cPanel search bar) and click Create Application.
  3. Fill in the form:
    • Node.js version: pick the version your app needs. The newest LTS version is usually best.
    • Application mode: Production for a live site.
    • Application root: the folder containing your code, for example myapp.
    • Application URL: the domain or subdomain, plus a path if you want one.
    • Application startup file: the file that starts your app, for example app.js or server.js.
  4. Click Create.
  5. If your app has a package.json, click Run NPM Install to install its dependencies.
  6. Click Restart, then visit your app's address.

Your app should listen on the port it's given, rather than a fixed one. For example, in Express:

const express = require('express');
const app = express();

app.get('/', (req, res) => res.send('Hello from Hoopla Hosting'));

app.listen(process.env.PORT || 3000);

To add environment variables, such as an API key or NODE_ENV, use Add Variable on the app's settings page, then click Save and Restart.

Set up a Python app

  1. In cPanel, open Setup Python App and click Create Application.
  2. Fill in the form:
    • Python version: pick the version your app needs.
    • Application root: the folder containing your code, for example myapp.
    • Application URL: the domain or subdomain, plus a path if you want one.
    • Application startup file: leave as passenger_wsgi.py.
    • Application Entry point: leave as application.
  3. Click Create. cPanel creates a passenger_wsgi.py file in your app folder.
  4. If your app has a requirements.txt, type requirements.txt under Configuration files, click Add, then Run Pip Install.
  5. Edit passenger_wsgi.py in File Manager so it loads your app (see below), then click Restart.

For a Flask app where the app object is called app in app.py, replace the contents of passenger_wsgi.py with:

from app import app as application

For a Django project called mysite:

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Remember to add your domain to ALLOWED_HOSTS in Django's settings.

Running commands for your app

At the top of your app's settings page, cPanel shows a command to enter the app's environment, for example:

source /home/yourusername/nodevenv/myapp/22/bin/activate && cd /home/yourusername/myapp

If Terminal is available in your cPanel, open it and paste that command. You can then run npm, node, pip or python commands, such as npm run build or python manage.py migrate, using the right version for your app.

Updating your app

Upload your changed files, run NPM Install or Pip Install again if your dependencies changed, then click Restart. Your app won't pick up code changes until it's restarted.

Troubleshooting

  • "We're sorry, but something went wrong" or a 503 error: the app failed to start. Check the stderr.log file in your app's folder, and see Find and read your website error logs.
  • "Cannot find module" or "ModuleNotFoundError": the dependencies aren't installed. Run NPM Install or Pip Install, then restart.
  • Changes don't show up: click Restart on the app's settings page.
  • The app is slow or keeps stopping: it may be hitting your plan's resource limits. See What are resource limits?

Need help?

If you get stuck, open a support ticket and we'll help.

Was this answer helpful? 0 Users Found This Useful (0 Votes)