Connection refused while using debugger - node.js

I have attached a node debugger to my JS file and after attaching the debugger to the js file which is a server running on port 8080 while I try to access it using localhost - it gives the following error message:
The node version is v6.11.2 and the debugger which gets attached is the one comes with the node(default) like
node debug JSONServer.js
The module used in the file are core modules http and https and the OS of the machine is Windows 10
connection refused
Please suggest what can be the reason.
Thanks

All,
Later I tried running the debugger from Atom with the package node-debugger
Still it gave same error
Connection Refused
Then I tried to attach the debugger outside Atom with following command
node --debug=5858 JSONServer.js
And Opened the debugger in Atom and this time the Debugger worked in Atom.

Related

Remote debugging Meteor / Nodejs with Atom

Can anyone help me using Atom for remote debugging a Meteor / Node app on another machine?
Have my meteor app with node inspector --inspect-brk running on a linux machine:
Debugger listening on ws://0.0.0.0:24010/3a1f6bec-6f4d-439a-b086-af78cc27c9ea
And on my windows machine i have the Atom editor and the source code.
I tried out different atom-debug packages, but to me they seem only to work when both Atom and Node / Meteor are on the same machine and also Atom can launch the meteor or node app itself.
In my case i want to attach to the remote debugger to a running instance on the other machine.
Does anyone know how it is done?
I think you need to specify an IP address to the inspect-brk parameter to get it to work remotely. You message is binding to 0.0.0.0 which cannot be seen remotely.
I think the format is —-inspect-brk=your.ip.address.here:portnumber entering a valid IP address fo the server and the port number you wish to debug on. This is from memory as I cannot see my startup code as I type this.

I get a EADDRINUSE error when I try to start a node.js server on OpenShift

So, I successfully commited a node.js app to OpenShift - without getting any error - but it does not work (error 503 when trying to access it through my browser, connection timeout when running tests against it from my local machine). The output when commiting says that node and mysql start successfully, and that the build succeeded.
I accessed the server through ssh, and checked the node log. It says an EADDRINUSE occured: Error: listen EADDRINUSE :::8080.
In my configuration, I use:
"server":{
"host":"OPENSHIFT_NODEJS_IP",
"port":"OPENSHIFT_NODEJS_PORT"
}
I also checked available environement variables in the shell with export and both are there, and 8080 is the right port.
When running ps in the shell, it does show only the programs ps and bash running. EADDRINUSE should mean that the port is already in use by another program, but I don't see anything running... I can't run netstat (permission denied).
I tried various combinations of stop/start/restart, but I always get the same error.
I am pretty lost at this point. Any pointers would be appreciated!
I found the problem. Locally, I used to start the server with app.listen(port);, which is enough to run it and access it on localhost. But that does not work on OpenShift. The host needs to be specified too: app.listen(port, host);.

my project's routes return 404 when WebStorm 7.0.1 is open

This is the situation:
WebStorm is open.
I run node app.js
I get : Server is listening on port 7777
I open chrome, and go to: localhost:7777.
I get: 404 Not Found WebStorm 7.0.1
when I close webstorm and do the same things everything works fine.
Anybody can help?
Thnx
You might have an instance of node already running: ps aux | grep node. If you do kill it and then use webstorm for running node.
OK,
The Webstorm Support helped me out...
My built-in server port was 7777. I changed this setting to another number and now everything works...

How do you debug a Node.js server running with Chrome/WebKit as the remote debugger?

If you have your Node running
node --debug server.js
This gives me a port number xxxx, should I use this port number when starting Chrome?
Do you remote debug into it from Google\ Chrome --remote-debugging-port=xxxx?
Or is the 9222 a magic port, as it is mentioned all over.
Am I on the right track, trying to start Chrome with --remote-debugger into the Node.js server.js
The node-inspector / --debug are now replaced by inspector
See update below
#now deprecated / see below for update
#install node-inspector
npm install -g node-inspector
#start node-inspector, listen on port 8080 (default)
node-inspector --web-port=8080
#in another terminal session/window:
#while node-inspector is running, start your project in debug mode
node --debug myproject.js
Now you can browse to http://your_server:8080 for a full debug session of myproject.js
If your remote server is not accessible on the remote port because of firewalls or other reasons, you could create an ssh-tunnel to it from port 8080 on your local machine to 'localhost:8080' on the remote server:
ssh -L 8080:localhost:8080 username#remoteserver -N
and keep this running while you use http://localhost:8080 on your local machine to debug your remote nodejs session
Update august 2017
Start node in inspect mode:
node --inspect=0.0.0.0:9229 myproject.js
or if you want the debugger to break at the first line of myproject.js:
node --inspect-brk=0.0.0.0:9229 myproject.js
Then open the following URL in your chrome browser:
chrome://inspect
Click the 'Configure...' button and add the following target:
ip-or-name-of-server-running-node:9229
After you click the 'Done' button, you should see myproject.js under your remote targets. Click the inspect link to start debugging. Unfortunately, the inspect link does not work on Chrome 58 for Ubuntu. It works fine on Chrome 60 for Windows.
Use node-inspector to remotely debug your node application from Chrome that you've started with the --debug option as you've shown.
Recent versions of Node (> v6.3.0) and Chrome now allow you to use the Chrome Developer Tools to debug a Node.JS process without having to install anything else. Just pass --inspect to node:
$ node --inspect script.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://SOME-URL-HERE
Just open that URL in Chrome, and you're good to go.
If you need to pause your script immediately after Node starts, you can also pass --debug-brk in the same command.
using
$ vagrant ssh -- -L 5858:127.0.0.1:5858
to ssh connect to VM. also this comment would start a proxy server on port 5858;
you could test using telnet 127.0.0.1 5858 to see if local proxy server started or not.
In VM, you can start node with command
$ node --debug-brk app.js
set up debug configuration in web storm.
when you start debug in web storm, node.js server in VM will start in a few seconds.
PS: there is no need to touch the vagrant file.
Reference: Connecting WebStorm to a remote node.js debugging session.

unable to run express 2.5.8 on ubuntu 11 on amazon aws

I am using express 2.5.8 on ubuntu 11 (amazon aws). I have connect 1.7.2 & node 0.6.15. I am able to run node (listen on port 3000 for instance) - however, when I use express, it appears to throw the following error:
got an uncaught error: Uncaught, unspecified 'error' event
There is no other service bound on that port at that time - I have tried re-installing express 2.5.8 and connect 1.7.2 (work on local box) - any insight to troubleshoot the issue more quickly will be greatly appreciated. Once again, the code (using express runs fine on local box - on server, I can run a non express node server on that same port (I close it down before I run the express server instance).
Thanks
Pilot error - the issue was with the redis connection pwd (I had to fix it in my code to match the pwd in the redis.conf to resolve the issue ). Added better handling (which I should have done to begin with).
Thank you Wes for commenting - appreciated.

Resources