Many Node.js tutorials pair an Express app with a free MongoDB Atlas cluster. On Domain India cPanel and DirectAdmin shared hosting, the Node.js part works, but the MongoDB Atlas part does not: the shared servers' outbound firewall does not allow MongoDB's port, so the app cannot reach the cluster. This guide explains what we measured, how to run your Node.js app on shared hosting with a MySQL or MariaDB database instead, and where to go if your app really needs MongoDB.
MongoDB Atlas is not reachable from Domain India shared hosting: on 23 September 2026 we confirmed that the outbound firewall on our cPanel and DirectAdmin servers does not allow port 27017, which Atlas uses. Run the app with the control panel's Node.js tool and use a MySQL or MariaDB database from the same panel. If you need MongoDB, use the App Platform (test the Atlas connection from your app first; PostgreSQL is included) or a VPS, where you control the firewall and can run MongoDB yourself.
1. Why MongoDB Atlas does not connect from shared hosting
A MongoDB Atlas cluster listens on port 27017. Your app on shared hosting has to open an outgoing connection to that port. The shared servers run a firewall that allows outgoing connections only to a list of ports, and when we checked the cPanel and DirectAdmin servers on 23 September 2026, 27017 was not on it.
What you see:
MongooseServerSelectionErrororMongoNetworkError, usually after about 30 seconds;- a timeout on the connection string's hosts, even though the same code works on your own computer;
- no change after you add the server's IP address to Atlas Network Access, because the block is on the outgoing side, not at Atlas.
The Atlas IP allow list and the hosting firewall are separate. Allowing an IP in Atlas does not open the port on the shared server.
MongoDB is not available from shared hosting, either as a local database or as an Atlas connection. If your app is built around MongoDB, choose the App Platform or a VPS before you start, rather than debugging timeouts on shared hosting.
2. Your options
| Where the app runs | Database | MongoDB? | Best for |
|---|---|---|---|
| cPanel or DirectAdmin shared hosting | MySQL or MariaDB from your control panel | No | Small apps and APIs next to a PHP or WordPress site |
| App Platform | PostgreSQL included with every plan | Atlas only if the connection works from your app; test first | Production Node.js apps with builds and steady traffic |
| VPS | Anything you install | Yes: install MongoDB yourself or connect to Atlas | Apps that need root access, MongoDB or several services |
3. Run the Node.js app on shared hosting
Our cPanel servers have Setup Node.js App, and our DirectAdmin servers have the same CloudLinux Node.js selector. When we checked on 23 September 2026, cPanel offered Node.js 20, 22 and 24; pick 22 or 24 if your app supports them. The short version:
- Prepare the app.Listen on
process.env.PORT, have one startup file such asapp.js, and build TypeScript or front-end code on your own computer. - Create the application.In cPanel open Setup Node.js App → Create Application, choose the version, set the application root (outside
public_html), the application URL and the startup file. - Upload your codewith File Manager or FTP, including
package.jsonand leaving outnode_modules. - Install and start.Click Run NPM Install, add environment variables in the same form, then click Start App.
The server runs your app behind Apache with Phusion Passenger, so you do not need, and cannot add, an Apache ProxyPass rule or a fixed port. The full guide, including DirectAdmin and troubleshooting, is Deploy a Node.js app on shared hosting.
4. Use MySQL or MariaDB instead of MongoDB
On shared hosting, the database that works is the one in your control panel.
- Create a database and a database user in cPanel or DirectAdmin, and give the user all privileges on the database. The names start with your account username and an underscore.
- Add the details as environment variables in the Node.js app form:
DB_HOST=localhost,DB_USER,DB_PASSWORDandDB_NAME. - Add the
mysql2package topackage.jsonand click Run NPM Install.
A connection pool with mysql2:
// db.js
const mysql = require('mysql2/promise');
const pool = mysql.createPool({
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
waitForConnections: true,
connectionLimit: 5,
});
module.exports = pool;// app.js
const express = require('express');
const pool = require('./db');
const app = express();
app.get('/products', async (req, res) => {
const [rows] = await pool.query('SELECT id, name, price FROM products LIMIT 50');
res.json(rows);
});
app.listen(process.env.PORT || 3000);If you prefer an ORM, Prisma, Sequelize and Drizzle all support MySQL. Keep the pool small: your app shares the account's resource limits. More on connecting in How to connect to the MySQL database.
5. If your app needs MongoDB
App Platform
The App Platform detects and builds Node.js apps automatically, runs each app in its own container and includes a PostgreSQL database, given to your app as DATABASE_URL. To use Atlas from it, add your connection string as an environment variable and test the connection from the running app before you rely on it, for example with a health route:
const mongoose = require('mongoose');
mongoose
.connect(process.env.MONGODB_URI, { serverSelectionTimeoutMS: 10000 })
.then(() => console.log('MongoDB connected'))
.catch((err) => console.error('MongoDB connection failed:', err.message));
app.get('/health/db', (req, res) => {
res.json({ mongo: mongoose.connection.readyState === 1 ? 'connected' : 'not connected' });
});Current Mongoose versions need no extra options: useNewUrlParser and useUnifiedTopology are deprecated and do nothing. If the connection fails, ask support before you plan around Atlas, or use the included PostgreSQL. See Getting started with the App Platform.
VPS
On a VPS you manage the firewall yourself, so you can connect to Atlas (add the VPS IP address in Atlas Network Access) or install MongoDB on the server. A Domain India VPS is self-managed and has no cPanel. See Installing MongoDB on a Domain India VPS.
6. Keep your connection string safe
- Store it in environment variables (the Node.js app form, the App Platform dashboard or your VPS service file), never in code or a file inside
public_html. - Create an Atlas database user with access only to the database your app uses.
- Do not open Atlas Network Access to
0.0.0.0/0to "fix" a connection problem. It does not help on shared hosting, and it exposes your cluster to the whole internet.
7. Troubleshooting
- Timeout connecting to Atlas from shared hosting: expected; port 27017 is not open outbound. Move the database to MySQL/MariaDB or the app to the App Platform or a VPS.
- The app page shows an error or 503: check the startup file and read the log named on the app's page, then restart the app.
- "Cannot find module": check that
package.jsonis in the application root and click Run NPM Install again. - Changes do not show: restart the app. On cPanel, add
?t=1to the URL to skip the page cache.
8. Where Domain India fits
For a small Node.js app with a MySQL or MariaDB database, cPanel shared hosting is enough. For a production app, or one that needs MongoDB, use the App Platform or a VPS. The cards show live prices, excluding 18% GST.
- 25 GB NVMe SSD Storage
- 50 GB Monthly Bandwidth
- 1 Website
- 10 Email Accounts
- 512 MB RAM per app
- 1 vCPU
- 5 GB NVMe SSD
- PostgreSQL Database
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
Can I connect to MongoDB Atlas from Domain India shared hosting?
No. On 23 September 2026 we confirmed that the outbound firewall on our cPanel and DirectAdmin shared servers does not allow port 27017, which MongoDB Atlas uses, so the connection times out. Use MySQL or MariaDB on shared hosting, or move the app to the App Platform or a VPS.
I added the server IP to Atlas Network Access. Why does it still fail?
The Atlas allow list only controls who Atlas accepts. The block is on the shared server's outgoing side, where port 27017 is not open, so the connection never reaches Atlas.
Can I run MongoDB on shared hosting itself?
No. MongoDB is not available on shared hosting. Your control panel offers MySQL or MariaDB databases.
Does the App Platform work with MongoDB Atlas?
Test it from your running app before you rely on it. Every App Platform plan includes a PostgreSQL database, which is the supported option; if an Atlas connection fails, ask support.
Where can I run MongoDB myself?
On a VPS. A Domain India VPS is self-managed, so you control its firewall and can install MongoDB or connect to Atlas from it.
Do I need an Apache ProxyPass rule for my Node.js app on cPanel?
No. Setup Node.js App runs your app behind Apache with Phusion Passenger. Listen on process.env.PORT and start the app from the control panel.
Ready to deploy? Put a small app on cPanel hosting with a MySQL database, move a production app to the App Platform, choose a VPS for MongoDB, or open a support ticket to ask which fits your app.
Node.js apps are detected and built automatically, with PostgreSQL and a free SSL certificate included in every plan.
See App Platform plans