sodcalculator

10 Tech How-To

Deploy Node.js App on GoDaddy Hosting

Guide 10-23959 · Updated · Step by step

This guide walks you through deploying a Node.js application on GoDaddy shared hosting or cPanel-based plans. You’ll learn how to prepare your app, upload files, configure Node.js via the cPanel interface, and get your site live. You’ll need a GoDaddy hosting plan that supports Node.js (most cPanel shared plans do), your app’s source code, and access to the cPanel dashboard.

What You’ll Need

  • A GoDaddy hosting account with cPanel (shared, VPS, or dedicated).
  • Your Node.js application code (files and package.json).
  • An SSH client (like PuTTY for Windows or Terminal for macOS/Linux) if you plan to use SSH.
  • An FTP client (like FileZilla) or the cPanel File Manager for uploading files.
  • Your GoDaddy username and password.

Step-by-Step

  1. Prepare your application locally. Ensure your app runs correctly on your local machine. Create a package.json file if it doesn’t exist (run npm init). Make sure you have a start script defined (e.g., "start": "node app.js"). Remove any environment-specific settings and use environment variables for sensitive data like database credentials.
  2. Compress your application files. Create a ZIP archive of your entire project folder (excluding node_modules). You’ll reinstall dependencies on the server, so excluding them keeps the upload small and avoids platform-specific binaries.
  3. Log in to your GoDaddy account and open cPanel. Go to your GoDaddy product list, find your hosting account, and click “Manage” or “cPanel Admin.” This opens the cPanel dashboard.
  4. Upload the ZIP file. In cPanel, open the “File Manager” (usually under the “Files” section). Navigate to the directory where you want to deploy the app. For a primary domain, this is typically public_html. For an addon domain, it might be public_html/yourdomain.com. Click “Upload” and select your ZIP file. Wait for the upload to complete.
  5. Extract the ZIP file. After the upload, right-click the ZIP file in File Manager and select “Extract.” Choose “Extract File(s)” and confirm. Once extracted, you can delete the ZIP file to keep things tidy.
  6. Find the Node.js selector in cPanel. Scroll through cPanel to find the “Software” section. Look for an icon named “Node.js Selector” or “Setup Node.js App.” Click it. If you don’t see it, your hosting plan may not support Node.js—contact GoDaddy support to confirm.
  7. Create a new Node.js application. In the Node.js Selector, click “Create Application” or “Add Application.” You’ll see a form with fields like:
    • Node.js version: Choose the version that matches your app’s requirements (e.g., 18.x or 20.x).
    • Application root: This is the directory where your app files are located. For example, if you extracted to public_html/myapp, enter myapp or the full path like /home/username/public_html/myapp.
    • Application URL: Select the domain and optionally a subdirectory (e.g., yourdomain.com or yourdomain.com/myapp).
    • Application startup file: This is the file that starts your app, usually app.js or server.js. Enter the filename, not the full path.
  8. Create the application. Click “Create.” cPanel will set up the app and show you a configuration screen. Note the “Application Root” and “Application URL”—you’ll need these later.
  9. Install dependencies. In the app’s configuration page, look for a tab or button that says “Run NPM Install” or “Install Dependencies.” Click it to install the packages listed in your package.json. Alternatively, you can use SSH to run npm install in the application root.
  10. Set environment variables (if needed). If your app uses environment variables, find the “Environment Variables” section in the Node.js app configuration. Add each variable (e.g., DB_HOST, PORT) with its value. This is also where you can set NODE_ENV=production.
  11. Start the application. After installing dependencies and setting variables, click “Start App” or “Restart App.” The status should change to “Running.”
  12. Test your app. Visit your application URL in a browser (e.g., https://yourdomain.com or https://yourdomain.com/myapp). You should see your app’s output. If you get a 404 or 500 error, check the “Logs” section in the Node.js selector for error messages.
  13. Set up a reverse proxy (if your app uses a port). If your app listens on a specific port (like 3000), cPanel usually handles the proxy automatically. However, if you’re using a custom port, you may need to configure a reverse proxy in cPanel’s “Apache Handlers” or use an .htaccess file. Most GoDaddy setups work without this step.

Common Mistakes

  • Uploading to the wrong directory. Placing files in public_html instead of the app’s root can cause conflicts with your main website.
  • Forgetting to install dependencies. If you skip npm install, your app will fail with “Cannot find module” errors.
  • Using an incorrect startup file. If you set the startup file to index.js but your app uses app.js, the app won’t start.
  • Hardcoding environment variables. Putting database passwords in your code is a security risk and can break when moving to production.
  • Not checking the Node version. Your app may use features not available in the default Node version on GoDaddy.

Tips

  • Use SSH for faster deployment. If you have SSH access, you can use Git to clone your repository directly to the server, then run npm install and start the app. This is much faster than uploading ZIP files.
  • Keep your app in a subdirectory. If you have a WordPress site on your main domain, deploy your Node.js app in a subdirectory like api to avoid conflicts.
  • Set up a process manager. While cPanel keeps your app running, using PM2 (via SSH) can give you more control, but it’s not required.
  • Use a .gitignore file. Exclude node_modules and .env files from your repository to avoid uploading them.
  • Test locally with the same Node version. Use nvm to match the Node version on GoDaddy to avoid surprises.

Troubleshooting

  • App shows 404 error. Check that the application URL is correct and that your app’s routes are set up properly. If you’re using a subdirectory, make sure your app handles the base path correctly.
  • App shows 500 error. Look at the error logs in the Node.js selector. Common causes: missing dependencies, syntax errors, or port conflicts.
  • App starts but stops quickly. This often happens when the app crashes due to an unhandled exception. Check the logs for the exact error message. Also, ensure your app listens on process.env.PORT or the default port GoDaddy provides (usually 3000).
  • Cannot find module ‘express’. Run npm install again. If the issue persists, delete node_modules and reinstall.
  • Environment variables not working. Make sure you’ve added them in the correct format (e.g., KEY=VALUE) and that you’ve restarted the app after adding them.
  • Node.js selector not available. Your hosting plan may not support Node.js. Contact GoDaddy support to upgrade or enable it.

Frequently Asked Questions

Can I deploy a Node.js app on GoDaddy’s basic shared hosting?
Yes, most cPanel shared hosting plans include the Node.js Selector. If yours doesn’t, you may need to upgrade to a VPS or dedicated server.

Do I need to use SSH to deploy?
No, you can use the File Manager and the Node.js Selector without SSH. SSH is optional and makes the process faster for frequent updates.

How do I update my app after deployment?
Upload the new files via FTP or File Manager, then go to the Node.js Selector and click “Restart App” to apply changes.

Can I run multiple Node.js apps on one hosting account?
Yes, you can create multiple applications in the Node.js Selector, each with its own root directory and URL.

What port should my app listen on?
GoDaddy automatically sets the PORT environment variable. Use process.env.PORT in your code to listen on that port.

Why does my app work locally but not on GoDaddy?
Common reasons: different Node versions, missing environment variables, or file path issues. Check the logs and compare your local setup with the server’s.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →