Knowledge Base
MilesWeb / Web Hosting FAQ

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

Approx. read time : 2 min

When you’re trying to use Node.js application, 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.

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”);

});

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.

Nehal Khatri
Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.