Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting FAQ  >  How to fix the Node.js Application error: “Cannot GET” URL?
Top Scroll

How to fix the Node.js Application error: “Cannot GET” URL?

 2 min

When you’re trying to use Node.js application on nodejs hosting, you might get an error about the app being unable to “Get a URL.”

The main cause is, Node.js implementation in cPanel uses Phusion Passenger to manage Node.js applications. When you create an app in Node.js cPanel, Passenger uses the value in the Application URL text box for creating the root path.

For example, if the application URL text box is set to ‘myapp’ then the root path for the app is not “/”but “/myapp”.

In this article, we will get know how to resolve this error.

How to Resolve the Error, Node.js application error message: “Cannot Get” URL?

Firstly, to resolve the issue, you need to include the application URL in your routes. The below code explains how to do this process using the very popular Express web application framework.

Related: How To Install Node.js On cPanel Server Via WHM?

It basically assumes that the Application URL text box in the Node.js app is set to myapp.

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

app.get(‘/myapp/’, function(req, res){

    res.send(“Hello from the root application URL”);

});

app.get(‘/myapp/test/’, function(req, res){

    res.send(“Hello from the ‘test’ URL”); });

});

app.listen(0, () => console.log('Application is running'));

In the above code sample, there are two codes defined,/myapp and /myapp/test. If your domain name is abc.com and you are using your web browser to view http://abc.com/my app or http://abc.com/myapp, you get the Cannot GET error message.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.