{"id":8609,"date":"2020-11-17T11:21:12","date_gmt":"2020-11-17T11:21:12","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=8609"},"modified":"2020-11-17T11:21:12","modified_gmt":"2020-11-17T11:21:12","slug":"node-js-application-error-cannot-get-url","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/","title":{"rendered":"How to Resolve the Node.js Application Error: &#8220;Cannot GET&#8221; URL?"},"content":{"rendered":"<p>In this article, you will get solution to a problem that may occur when you are running a Node.js application using cPanel&#8217;s Node.js Selector.<\/p>\n<h3>Problem<\/h3>\n<p>A Node.js application can be created using cPanel&#8217;s Node.js Selector. When you try to view a page generated by the application, you get the below error message:<\/p>\n<pre class=\"lang:default decode:true \">Cannot GET \/url\/<\/pre>\n<p>Here, url means the path you are trying to view.<\/p>\n<h3>Cause<\/h3>\n<p>Phusion Passenger is used by the Node.js Selector to manage Node.js applications. When an application is created in the Node.js Selector, the value in the Application URL text box is used by the Passenger to create the root path. For example, suppose the Application URL text box is set to myapp, then the root path for the application is \u201c\/myapp\u201d and not \u201c\/\u201d.<\/p>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info kb-wisdom-wrapr-blue\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p><strong>Note:<\/strong> This is a completely different behavior from most other web environments, where \u201c\/\u201d is typically the root path.<\/p>\n<\/div>\n<\/div>\n<h3>Resolution<\/h3>\n<p>For resolving this issue, it is important to include the application URL in the routes. The below code sample represents the way of using the popular Express web application framework. Here let\u2019s assume that the Application URL text box in cPanel&#8217;s Node.js Selector is set to myapp:<\/p>\n<pre class=\"lang:default decode:true \">const express = require('express');\r\nconst app = express();\r\n\r\napp.get('\/myapp\/', function(req, res){\r\nres.send(\"Hello from the root application URL\");\r\n});\r\n\r\napp.get('\/myapp\/test\/', function(req, res){\r\nres.send(\"Hello from the 'test' URL\");\r\n});\r\n\r\napp.listen(0, () =&gt; console.log('Application is running'));<\/pre>\n<p>Here, two routes are defined, \/myapp and \/myapp\/test. Suppose your domain name is example.com, and you use your web browser to view http:\/\/example.com\/myapp or http:\/\/example.com\/myapp\/test, the pages get loaded as expected. But, if you visit any other URL under http:\/\/example.com\/myapp, you get the Cannot GET error message.<\/p>\n<h3>Also Read<\/h3>\n<p><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/setup-node-js-end-user-interface\/\" target=\"_blank\" rel=\"noopener\"><strong>Steps to Setup Node.js for Web Applications Using End User Interface<\/strong><\/a><\/p>\n<p><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-install-node-js-on-ubuntu-16-04\/\" target=\"_blank\" rel=\"noopener\"><strong>How to Install Node.js on Ubuntu 16.04?<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, you will get solution to a problem that may occur when you are running a Node.js application using cPanel&#8217;s Node.js Selector. Problem A Node.js application can be created using cPanel&#8217;s Node.js Selector. When you try to view a page generated by the application, you get the below error message: Cannot GET \/url\/ [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[1668,565,566,1667],"class_list":["post-8609","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-cannot-get-url","tag-node-js","tag-node-js-application","tag-node-js-application-error"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Resolve the Node.js Application Error: &quot;Cannot GET&quot; URL?<\/title>\n<meta name=\"description\" content=\"The article represents steps to resolve the Node.js Application Error: &quot;Cannot GET&quot; URL by using popular Express web application framework.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Resolve the Node.js Application Error: &quot;Cannot GET&quot; URL?\" \/>\n<meta property=\"og:description\" content=\"The article represents steps to resolve the Node.js Application Error: &quot;Cannot GET&quot; URL by using popular Express web application framework.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-17T11:21:12+00:00\" \/>\n<meta name=\"author\" content=\"Pallavi Godse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Godse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/\",\"name\":\"How to Resolve the Node.js Application Error: \\\"Cannot GET\\\" URL?\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2020-11-17T11:21:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"The article represents steps to resolve the Node.js Application Error: \\\"Cannot GET\\\" URL by using popular Express web application framework.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Resolve the Node.js Application Error: &#8220;Cannot GET&#8221; URL?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\",\"name\":\"Pallavi Godse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"caption\":\"Pallavi Godse\"},\"description\":\"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Resolve the Node.js Application Error: \"Cannot GET\" URL?","description":"The article represents steps to resolve the Node.js Application Error: \"Cannot GET\" URL by using popular Express web application framework.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/","og_locale":"en_GB","og_type":"article","og_title":"How to Resolve the Node.js Application Error: \"Cannot GET\" URL?","og_description":"The article represents steps to resolve the Node.js Application Error: \"Cannot GET\" URL by using popular Express web application framework.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2020-11-17T11:21:12+00:00","author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/","name":"How to Resolve the Node.js Application Error: \"Cannot GET\" URL?","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2020-11-17T11:21:12+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"The article represents steps to resolve the Node.js Application Error: \"Cannot GET\" URL by using popular Express web application framework.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/node-js-application-error-cannot-get-url\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Resolve the Node.js Application Error: &#8220;Cannot GET&#8221; URL?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945","name":"Pallavi Godse","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","caption":"Pallavi Godse"},"description":"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/"}]}},"views":512,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=8609"}],"version-history":[{"count":1,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8609\/revisions"}],"predecessor-version":[{"id":8610,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/8609\/revisions\/8610"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=8609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=8609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=8609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}