Bluehost通过cPanel部署Node.js+Express应用后域名仅显示Index of/的问题排查求助
Troubleshooting Node.js+Express Deployment on Bluehost cPanel
Hey James, you’re absolutely right—you’re so close to getting this working! Let’s break down the likely issues and fix them step by step:
1. Verify Domain Mapping in cPanel’s Application Manager
The most common culprit here is that your domain deltadesigns.co isn’t mapped to your Node.js application yet. Here’s how to check:
- Log into your cPanel account and navigate to the Node.js Selector or Application Manager (the name might vary slightly depending on your Bluehost plan).
- Locate the Node app you registered for your project, then click Manage.
- Look for the Domain Mapping section. If
deltadesigns.coisn’t listed here, click Add Domain, select your domain from the dropdown, and confirm the root path points to yourDeltaDesigns22directory (where yourapp.jslives). - Ensure the Application URL is set to your main domain, not a subdirectory path.
2. Check Your .htaccess Configuration (Critical!)
Bluehost relies on .htaccess to route domain requests to your Node.js server. If this file is missing or misconfigured, your domain will just show the default directory index.
- Navigate to your domain’s document root (usually
public_html, or the folder assigned todeltadesigns.coin cPanel’s Domains section). - Create or edit the
.htaccessfile and add these rewrite rules to proxy all requests to your Node server:
RewriteEngine On RewriteRule ^$ http://127.0.0.1:3000/ [P,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]
- Save the file and refresh your domain. Note: If the Application Manager already generated a
.htaccessfor you, double-check it has similar proxy rules—don’t duplicate them.
3. Confirm Your Node App is Running & Configured Correctly
- Go back to the Application Manager for your app and make sure the Status shows as Running. If it’s stopped, click Start.
- Verify the Startup File is set to
app.jsand the startup command matches what you tested manually:/opt/cpanel/ea-nodejs10/bin/node app.js. - Quick check: Update your Express app’s listen code to ensure it’s accessible to the local proxy. Change your
app.listenline to:
app.listen(3000, '0.0.0.0', () => { console.log('Server running on http://0.0.0.0:3000'); });
Restart the app after making this change.
4. Double-Check Your Domain’s Document Root
- In cPanel, go to Domains > Domains and find
deltadesigns.co. - Check the Document Root setting. It should point to your
DeltaDesigns22directory (not the parentpublic_htmlfolder). If it’s set topublic_html, update it topublic_html/DeltaDesigns22(adjust the path if your folder is in a different location).
5. Test with Fresh Cache & External Tools
- Clear your browser’s cache (press
Ctrl+F5to force a hard refresh) or open your domain in an incognito window—sometimes old cached directory listings stick around. - Run
curl http://deltadesigns.cofrom a local terminal (not just the WHM server) to see what response you get. If it still returns the directory index, the issue is definitely on the server side.
Give these steps a try, and I bet one of them will get your Express app loading correctly at deltadesigns.co!
内容的提问来源于stack exchange,提问作者JamesArthur
相关产品推荐
相关产品推荐

