Mean.IO does not work on Redhat 6.5 VM - node.js

I am developing an application based on MEAN.IO, it works fine on my local Windows 7 machine, so I want to publish the app.
I have a remote Redhat 6.5 virtual machine (VM) server which can be used to host my application for public access. After uploading and run the app with grunt, it stops with an error:
$ grunt
Running "hook" task
Starting hooked tasks.
Running "clean:0" (clean) task
0 paths cleaned.
Running "jshint:all" (jshint) task
42 files lint free.
Running "csslint:src" (csslint) task
5 files lint free.
Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] v1.2.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node --debug server.js
debugger listening on port 5858
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
[nodemon] app crashed - waiting for file changes before starting...
I also tried to clone the code into the server directly from https://github.com/linnovate/mean.git, without ANY changes and run the app, but I got the same error as above.
I tried run node server.js instead of grunt, I got similar errors as below:
[jking#server eclipse_test]$ node server.js
for real!
forking 0
forking 1
forking 2
forking 3
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
Worker 3 died :(
events.js:72
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer [as oncomplete] (dns.js:124:16)
Worker 2 died :(
...
__________________________________________________________
I don't know if it is due to the virtual machine or the mean.io stack.
Can someone give me any clue or answer to resolve it?
thanks
-John

I had the same problem and struggled all day with it until I found this:
https://forums.aws.amazon.com/thread.jspa?messageID=622248
Basically in my instance Amazon's linux image did not have the computer name associated with 127.0.0.1.
My instance was named ip-10-0-0-117 so I changed /etc/hosts from:
127.0.0.1 localhost localhost.localdomain
into
127.0.0.1 localhost localhost.localdomain ip-10-0-0-117
and everything works!

Related

Error: EADDRINUSE on Mac - even though nothing is using the port?

Alexs-MacBook-Pro:build alexnordhausen$ gulp server:start
[21:11:22] Using gulpfile ~/Documents/Kanvasroom_Support/kanvasroom/build/gulpfile.js
[21:11:22] Starting 'env:dev'...
Application loaded using the "development" environment configuration
[21:11:22] Finished 'env:dev' after 6.25 ms
[21:11:22] Starting 'server:start'...
[21:11:22] Finished 'server:start' after 1.95 ms
[21:11:22] [nodemon] 1.11.0
[21:11:22] [nodemon] to restart at any time, enter `rs`
[21:11:22] [nodemon] watching: *.*
[21:11:22] [nodemon] starting `node --debug=5858 --trace-warnings server.js`
Server started, be sure the user content server is also running with gulp user-content
Live-build the client with gulp web:dist
Debugger listening on 127.0.0.1:5858
[Busy] Launching SocketCluster
Error: listen EADDRINUSE 127.0.0.1:5858
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Agent.Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at doListening (net.js:1397:7)
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
There aren't any ghost processes running... this was working just fine until I did a fresh npm install of the whole project. Thoughts?
As per the logs, you are using clustering. You might be trying to listen from each child process on same port, which will throw error after when second child process got launched.
I can see in your log:
Your master server started on 127.0.0.1:5858.
Then SocketCluster try to starting on 127.0.0.1:5858
So if you one server is already 5858 port, Then how can other server use 5858 ?
So plese change the port for solving the issue.
This error comes when more then two app using a single portno.
Use this command
1) `netstat -tulpn` (Commans for show all the process on server)
2) then kill the process with the process number. like kill 2043

Cloud9 + sails.js + phpmyadmin

I have problem with creating basic sails.js application on Cloud9 environment and connecting it to MySQL.
Steps I'm making:
Creating Cloud9 project
installing sails: npm -g install sails
creating project: sails new test
lifting: cd testProject/ and sails lift
Here it's working
Adding mySQL support: mysql-ctl start
still working
adding phpMyAdmin support: phpmyadmin-ctl install
And here, my application stops working. I'm getting exception:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:905:11)
at Server._listen2 (net.js:1043:14)
at listen (net.js:1065:10)
at Server.listen (net.js:1139:5)
at Array.async.auto.start [as 0] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:29:35)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:484:38
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.async.auto (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:455:9)
at Sails.startServer (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/hooks/http/start.js:16:11)
at Sails.emit (events.js:92:17)
at Sails.emitter.emit (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/after.js:50:11)
at afterBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:56:11)
at bootstrapDone (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:51:14)
at Object.module.exports.bootstrap (/home/ubuntu/workspace/testProject/config/bootstrap.js:16:3)
at Sails.runBootstrap (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/bootstrap.js:44:25)
at Sails.bound [as runBootstrap] (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at Sails.initialize (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/private/initialize.js:48:9)
at bound (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:607:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:246:17
at iterate (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:146:13)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:157:25
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:248:21
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:612:34
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/lib/app/load.js:201:13
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.taskComplete (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:354:15)
Additionally I'm getting info about problem with starting my app, and ability to kill the process. Of course killing does not help.
Could youplease help me with that?
So what's happening is that you're starting your sails server, which binds to port 8080, and then you try to install phpmyadmin which tries to start apache (at port 8080 too!) causing it to actually fail since the port is already in use. You will have to stop sails before trying to install / run phpmyadmin since two servers can't listen on the same port.

How do you debug nodejs projects?

For the past 16 hours or so, I've been trying to get a MEAN stack project working on my computer.
I started with the Yeoman angular-fullstack project. But that was giving me all kinds of errors so I just gave up on it.
Then I followed some tutorials which helped me get started but didn't cover a ot of my questions.
Then I found mean.io which offers a full boilerplate MEAN stack project, which I followed the instructions to set up. Unfortunately, when I try to run it, I get all kinds of errors again :-(
The worst part about is, that it says NOTHING about what/where is causing the error.
Can someone help me figure it out? Please :-)
The latest error I'm getting is when I run grunt.
C:\Users\Imray\projects Practice\meanIO\meanApp>grunt
Running "hook" task
>> Starting hooked tasks.
Running "clean:0" (clean) task
>> 0 paths cleaned.
Running "jshint:all" (jshint) task
>> 42 files lint free.
Running "csslint:src" (csslint) task
>> 5 files lint free.
Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at ExpressEngine.beginBootstrap (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\lib\core_modules\server\E
xpressEngine.js:123:14)
at Meanio.serveWithDb (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\lib\core_modules\server\index.js:14
:10)
at Consumer.Dependable.runAction (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-depend
able\index.js:72:22)
at Consumer.Dependable.fire (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependable\
index.js:69:53)
at Consumer.onResolved (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependable\index
.js:119:8)
at Consumer.Dependable.resolve (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependab
le\index.js:55:10)
[nodemon] app crashed - waiting for file changes before starting...
According to your output you have Error: listen EADDRINUSE.
It means that you already have running process on this port.
Try to investigate which process uses this port by typing:
sudo lsof -n -i4TCP:$PORT_NUMBER | grep LISTEN
Kill that process and restart your application.
If you need that process, change your application port.
EADDRINUSE is a low level system error, that usually means there's something else running on the port number you're using. Try using a different port.
EDIT: Note that it may not just be the actual server who's port is invalid. It looks like your deployment script creates a debugger, and possibly other services that listen on various ports, so they might need to be changed instead.
The problem went away after I restarted my computer. Not sure why, but I'll take it.

Forever Crashes and Doesn't Restart after 4 times

I have a node server running on AWS and I am using forever to keep it running in the background.
I have been very happy with forever so far; it's super easy to set up and use. However, even though my app is very simple, sometimes it crashes with this error:
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
error: Forever restarting script for 4 time
When I look back at the logs, I can see that this has happened 4 more times, and each time forever manages to restart the server. However, when it happens for the 5th time, for some reason forever fails to restart the server and my app becomes unresponsive.
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/ev$
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:332:26
at process._tickCallback (node.js:415:13)
Has anyone else experienced similar problems?
You have to use the option -MAX like this:
forever -MAX 10000000000 Mypath/ToMyFile.js
Also put a -minUptime for the minimum time the server can stay up, if it crash before that laps of time then it won't go up again so set it to 1.
forever --minUptime (number-in-milisecond-here) -MAX (number-of-restart-here) path/file.js
Just try this:
forever --minUptime 1 -MAX 1000000000 YourPath/ToYourFile.js
More documentation there
https://www.npmjs.com/package/forever
To allow a max of 100 restarts when the server crashes
forever start -m 100 index.js

Error: Connection refused issue when trying to connect to a mqtt enabled node server hosted on heroku

So I basically wanted to host a mqtt pub/sub-enabled node server on Heroku. These are 2 guides I refer to:
https://github.com/adamvr/MQTT.js and https://gist.github.com/1826931
The mqtt pub/sub worked well when tested on localhost, deployment on heroku was fine, but when I tried testing on Heroku it didn't work
I tried 2 commands to subscribe, both showed the same errors.
Command 1:
mosquitto_sub -p <port> -h <host> -t <topic>
Error 1:
Error: Connection refused
Unable to connect (13).
Command 2:
mqtt_sub <port> <host> <topic>
Error 2:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: connect ECONNREFUSED
at errnoException (net.js:670:11)
at Object.afterConnect [as oncomplete] (net.js:661:19)
My main.js (server) code is similar to this one - https://gist.github.com/1826931. The error seems more like a node problem than a mqtt pub/sub problem, and I am new to node, so not quite sure how to debug it. I put in some console.log lines but as expected it didn't print since it's not connected. There is a dyno running node main.js on Heroku fine.
Process State Command
------- ---------- ------------
web.1 up for 35m node main.js
Appreciate any advice on this issue.

Resources