Debugging with node-inspector: Cannot GET / - node.js

I am running a Nodejs server with an application which I want to debug.
In order to achieve this using node-inspector I run the app as follows:
node-debug server.js
Unfortunately I can not access the webserver via URL anymore. Visiting http://127.0.0.1:8080 results in
Cannot GET /
However if I start the application the usual way with
node server.js
everything is fine (except for the fact that I can not debug). But I can access http://127.0.0.1:8080.
The '/' request is also not logged so it seems that it never reaches the server.
Hence the problem I have is: I can access the remote debugger via http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 but I can not start debugging because I can not trigger any action on the webserver via URL.
Oh and the debugger is not paused or anything. I skipped the first break point.

I resolved the problem by choosing a different port than 8080. It seems like the debugger uses this port. I was not aware of that because this port was familiar to me as I used it for my application.

As Schnodderbalken already answered, the problem lies in the application and inspector both using the same port 8080. If you tell inspector to use a different web port, 8082 for instance, the problem is solved.
You can do this by adding a parameter like so:
node-inspector --web-port=8082
You can then access inspector via http://127.0.0.1:8082/?port=5858

Related

Cannot establish connection using port number explicitly

I am new to servers and networking so pardon my ignorance.
I have a Heroku application running a NodeJS server. I am using console.log() to output the port its using to the console. But when i use the port to try to perform a GET request from my browser it keep loading forever. My request is something this:
https://example.herokuapp.com:28222/getHighest
When i remove the port number, it works perfectly:
https://example.herokuapp.com/getHighest
I am ultimately trying to perform GET and POST request from a C application. The HTTP library i am using seemingly requires a port for a connection. I am using this library: GitHub. It works perfectly when i run it locally with localhost:8080/getHighest but not when i use my heroku app.
As suggested by #tadman using the default https port 443 solved the issue.

node server is not working

i am working on angular 6 and node js. While i go to fetch data from database and run node server then at localhost:3000 page doesn't works but when i run ng serve then it works on localhost:4200 but doesn't show data coming from database.
There might be many reasons for that. I can say nothing until I see the code.
But some reasons for that might be 1. 3000 port is not listening to your node it may be busy
2. localhost:3000 spelling should be correct in the browser 3. problem might be in body parser when you use it incorrectly, you will be in trouble.
Hope you will fix it.
Angular is running on 4200 port and node is running on 3000. Both are working on different servers. may be an issue of cross-domain. Implement CORS on Node, as it is receiving requests, this will solve your problem.

Why does my express.js app never loads?

I did everything as specified here:
https://expressjs.com/en/starter/hello-world.html
When I try to reach my domain, and append :3000 to the end, it just never loads (timeout).
If you did everything specified on https://expressjs.com/en/starter/hello-world.html and it didn't work then it must mean that the tutorial is incorrect.
If, on the other hand, you didn't do everything as specified in the tutorial (which we will never know since you didn't post what you actually did) then you should make sure to follow the tutorial more closely because it doesn't look incorrect.
The reasons why trying to reach a random domain on a random port times out can be:
wrong port
wrong domain
bad DNS record
misconfigured DNS resolver
firewall rules
server not listening
server listening on a different port
server listening on a different interface
Unfortunately you didn't provide enough information for a better answer, with that said the most likely issue is that you never actually executed the JavaScript file you created. You'll want to make sure Node is installed and run:
nodejs app.js
Keep in mind that in some distros node doesn't exist, but nodejs does, when installing node from a package manager or other installer.
EDIT
There are other potential issues you'd run into if you don't have port 3000 opened up if you're not running it on localhost.

Node.js app works on 127.0.0.1:8080, but does not work on localhost:8080

I have problem with my Node.js server. I suppose it's not about Node itself, but I'm not sure.
When I start server on port 8080, accessing it from localhost:8080 will leave me with blank page, however if I access it from 127.0.0.1:8080 it works perfectly. Normally I would look at hosts file and see if there are some problems. But here is a trick, if I run server on 1337 port (or any other) it will work for both cases, localhost:1337 and 127.0.0.1:1337.
For smart guys I did a lot of searching out there, but there is no good explanation why this is happening.

How do I, in nodejs, set up a Mongo viewer (like Mongo-Express) on the same port as my main app?

I'm new to just about everything with regards to nodejs and Mongodb but I managed to get a simple app up and running and now I want a database viewer. I found Mongo-Express and installed it on my localhost where it works fine. The viewer is configured in a config file with host a baseUrl and port.
The problem is on the live server (AppFog) where I only have one port available which is occupied by my main app. How do I solve this issue? Can they run on the same port or is there another viewer available that doesn't need to run on a separate port?
I can recommend MongoMate which can either run as a standalone MongoDB Browser or (what you want) it can be mounted within an Express app. See the webpage for more info.
PS. I built MongoMate :P

Resources