Get the " listen EINVAL" when starting up Node.js server, Why? - node.js

After I upgrade to Node 0.6.18, I got the error: listen EINVAL when start.
It seems not it cannot find the file I'm running.
e.g. i run node myserver.js
and then it says myserver.js throw EINVAL which seems to be a file not found error.
however, I'm not sure. What is that?

From the listen(3p) man page:
EINVAL The socket is already connected.
Make sure something isn't already listening on that port.

Related

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

Unhandled rejection SequelizeConnectionError: connect ENOENT

I am stuck at a point. I am trying to start /connect using command "npm start" but unable to start npm on server.
I am getting this error:
Unhandled rejection SequelizeConnectionError: connect ENOENT
at Handshake._callback (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:63:20)
at Handshake.Sequence.end (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at Protocol.handleNetworkError (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/protocol/Protocol.js:358:14)
at Connection._handleNetworkError (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/Connection.js:382:18)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
Apart from this my website work on nodejs & have nginx server configured on server.
Every thing started when I tried to set apache for adding a wordpress blog website. Since nginx already working on port 80. I was trying to set apache on another port so that everything work and ended up with above error. Now my website is not starting at all.
Edit:
My website is running using nodejs. I needed a wordpress blog website to run along and so i checked if there is a scope for apache on my server.
I found that apache along with nginx service was already running and mysql as well.
nginx is essential to run "adminer", a database management tool
Since nginx and apache was running on same ports, i tried to set apache on another port, other than default port.
After that I restarted apache, stopped mysql, stopped nginx and also stopped node
I used pkill node command for stopping node service.
Then restarted everything but got the above error.
I tried many things, and finally reset everything.
Ever since then I am stuck on this error.
Can anyone help?
I finally figured the problem and solved it.
Connect ENOENT means that system is unable to connect to mysql because its path is not correct.
As mentioned in an approved answer from Connect MySQL with Sequelize
Update your models/index.js file with the mentioned code.
To find you mysql socket path go to file here /etc/mysql/my.cnf ( this path may depend on your server). For my case it was /etc/my.cnf. Here you will find the socket path. Now paste this path to the code above and do npm start.
Problem is resolved. :)

Listen EADDRINUSE error while debugging in sails

I am trying to debug my code using node-inspector but I am getting this error in my Terminal window again and again
$ sudo sails debug
info: Running app in debug mode...
info: You probably want to install / run node-inspector to help with debugging!
info: https://github.com/node-inspector/node-inspector
info: ( to exit, type <CTRL>+<C> )
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Agent.Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Agent.Server.listen (net.js:1267:5)
at Object.start (_debugger_agent.js:20:9)
at startup (node.js:86:9)
at node.js:814:3
To resolve
Error : listen EADDRINUSE
I have tried closing other Terminal window (in which my node-inspector was running).
I have referred to the answers already here on StackOverflow but they didn't work
I have even tried giving this command to kill processes :
$ killall -9 node
No matching processes belonging to you were found
but still its not working.
Somebody please help me out with this.
I see that you are using sudo so this is not a permissions issue.
It definitely seems like the port is already in use. You should check to see which process is using the port, then kill that process.
There is a known issue with using sails debug on Node v12.0. There's a patch which will be released with the next version of Sails (v0.12).
In the meantime you can either install the edge version of Sails from Github or apply the patch yourself by replacing your Sails' /lib/hooks/grunt/index.js file with the contents of https://raw.githubusercontent.com/balderdashy/sails/88ffc0ed9949f8c74ea390efb5610b0e378fa02c/lib/hooks/grunt/index.js.
First, find your task that uses port 1337:
netstat -ano | findstr : 1337 (port number)
Then kill it:
tskill (process ID (PID))
It can solve your problem

Binding IPv4 and IPv6 socket failure

I installed a license server for a software and run this server on a Linux machine. The execution of the license server is something like:
./exefile -logfile log -loglevel 4
where I ask all log info to be written in the file named log.
Everything is running smoothly but when checking the file log, I see the error messages:
"Binding IPv4 socket" "Failure. Socket 16286 probably already in use"
"Binding IPv6 socket" "Failure. Socket 16287 probably already in use"
It seems that this error makes it impossible for the server to record the ip addresses of the machines who (successfully) run the program but I cannot understand the message or find how to solve this error...
Any idea ?
Thanks.
Ok, so to sum up, thanks to Marc's comments I was able to see that the first run of the license server created a process that was using sockets 16286 and 16287 using the command:
netstat -ap
After killing this process and restarting the license server, everything works well.

Error: listen EADDRINUSE when trying to run an Express.js application?

When I try to run my application an Express.js server, the first time with a new port works fine, but then when I try to run it again on that port, I get the "Error: listen EADDRINUSE" error.
I already tried killing all the possible node/gulp processes, also, checked netstat and I do not see port 8080 being used by anything.
What could be the culprit?
This usually happens if the node process is still running your app when you go to run it again. Express will try to bind to the same port but it's already being use by the last node instance you created.
Kill all node processes and try again.
I know that this post is very old. But right now I saw something.
When I was in the same situation as you are in, I opened the console in my browser and I can see some errors. When I solved those errors, everything works fine.

Resources