I'm running a simple MERN stack application on my local server(macOS). Although I figured out how to kill the process using the below statement, I wonder if there is a way to prevent getting EADDRINUSE error often?
kill -9 <PID>
I've been getting this error very regularly and it's affecting my productivity to kill and restart the server many times. Any insights on it?
Using nodemon v1.18.9 to monitor changes and start the server.
I'm trying to get meteor reset to work in vagrant box. However I kept getting errors. This is my error message:
/home/vagrant/.meteor/packages/meteor-tool/.1.1.10.8ogiso++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:278
throw(ex);
^ Error: EBUSY, rmdir '/vagrant/foosboom-meteor/.meteor/local'
at Object.Future.wait (/home/vagrant/.meteor/packages/meteor-tool/.1.1.10.8ogiso++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:398:15)
at Object.rm_recursive (/tools/fs/files.js:270:9)
at Command.main.registerCommand.name [as func] (/tools/cli/commands.js:1211:9)
at /tools/cli/main.js:1378:23
I'm using hashicorp Otto as my development environment.
I have performed a mount on the local folder as suggested by one of the user here.
Any idea what seems to be the problem? Thanks.
After mounting you can't reset your mongo so do this
sudo umount -f /vagrant/foosboom-meteor/.meteor/local
I'm running http://socketcluster.io/ and I want to restart my workers whewnever a file changes. However, nodemon server.js fails as soon as it tries to restart with an endlessly-repeating wall of:
1445633138359 - Origin: Worker (PID 44372)
[Error] Error: connect ECONNREFUSED /var/folders/fj/yzfd3_tn7xd0smz7j6s093mh0000gn/T/socketcluster/6879fe94-ed92-4188-b1d7-cb187a5ade4e_b68fcded6c/b0
at Object.exports._errnoException (util.js:874:11)
at exports._exceptionWithHostPort (util.js:897:20)
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
1445633138362 - Worker 0 exited - Exit code: 0
How can I safely restart SocketCluster to load the new changes?
nodemon sends the SIGUSR2 signal to the main (Master) process. SocketCluster (correctly) interprets this as as a request to reboot the workers. Unfortunately, there's an open issue where things are not shut down properly and errors fly all around.
There are two options:
You can add the code from the linked issue:
house.addShutdownHandler(function(ctx, next){
socketCluster.killWorkers();
socketCluster.killBrokers();
next();
});
or use forever to send a "restart everything" signal:
forever -w --killSignal=SIGTERM server.js
Improvements were made for nodemon in SC version 5.0.23 or later.
Make sure that you pass killMasterOnSignal: true when instantiating SocketCluster in your code (server.js file) - This setting is necessary for nodemon to work.
I have installed node, npm in my Centos 6 server, and i am using putty for running commands at server.
Node is installed correctly at root and running awesome at anywhere at server.
my project is at /home/shaadise/public_html/Ikon
I have created a hello.js file /home/shaadise/public_html/Ikon
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8080);
console.log('Server started');
while running js:
root#vps [/home/shaadise/public_html/Ikon]# node hello.js
Server started
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 Object.<anonymous> (/home/shaadise/public_html/Ikon/hello.js:6:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
root#vps [/home/shaadise/public_html/Ikon]# throw er; // Unhandled 'error' event
-bash: throw: command not found
-bash: //: is a directory
Question: where i have to put my node js file and how can i access it????
i tested to run command:
root#vps [/home/shaadise/public_html/Ikon]# netstat -plnt | grep ':8080'
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 27111/nginx
This Error: listen EADDRINUSE categorically means that either you or a daemon is running another application on 8080.
However, to check, try running on a different port?
-edit- as this is getting quite a few upvotes, I thought i'd add a bit of additional debug into it.
Pretty much all node.js tutorials default to port 8080 for running. This is because it is similar to the default port 80 used by other web services, such as Apache or NGinX.
In order to determine if another application is running on the same port, you can use netstat -a to see all active connections and their ports, and then grep that list to find any process connected on the same port as your Node.js application.
It doesn't really matter which port your Node application runs on, as long as it's a free port. Ultimately, when you deploy into production, you would sync up whatever content server you are using (Apache/NGinX) to use the same port.
A common situation to get this error is when one does the following:
startup something
use Ctrl+z and put it into background
try to startup something again
The good way to go would be always try to hit Ctrl+c first which sends signal to the application (which may decide to shutdown).
You can read more about it here:
What is the difference between Ctrl-z and Ctrl-c in the shell?
The server is running in background; it's happing, usually, when you don't kill the process.
To solve this you can put on the terminal:
ps | grep 'node'
This code will show you a process that have a specific number, use the next code to kill the process:
kill -9 "specific number"
You can use sudo if this doesn't work correctly.
If you are using Linux based system, first you have to list all the programs that are using that particular port and kill them(meaning stop them)
exemple: I want to list all programs that are using the 3000 port
fuser 3000/tcp
then pick the process ID, which is in the right side of the obtained line of text and issue the kill command
exemple : if have a process ID with the value of 2345 then the command will be
kill 2345
If closing the process which is using that port doesn't fix it , try the below solutions.
Installing the below package fixed it for me forever.
npm install ws#3.3.2 --save-dev --save-exact
Run this command in your terminal :
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:
fs.inotify.max_user_watches=524288
Then execute:
sysctl --system
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details
I installed Meteor for windows from here :
http://win.meteor.com
The server crashes almost every time I try to make live code push.
I would then have to end the mongod.exe process and run 'meteor reset' and 'meteor' to start it up back again.
Here are the logs:
=> Meteor server restarted
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:519:19)
at Socket.write (net.js:511:15)
at Socket.HttpProxy.proxyWebSocketRequest.reverseProxy.incoming.socket.on.listeners.onOutgoing (C:\Program Files\Meteor\lib\node_modules\http-proxy\lib\node-http-proxy\http-proxy.js:515:35)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14)
Anyone on the same boat? I read from here https://github.com/meteor/meteor/issues/513 that this has been an open issue for over 6 months.
Someone's got any workaround? Help appreciated.
The EADDRINUSE issue was fixed in 0.6.3.1-rev4, but please update to version 0.6.4 as this problem seems to have resolved the other issue by the update to the http-proxy package.
For MSI downloads see https://github.com/sdarnell/meteor/wiki/Windows
Should also appear on http://win.meteor.com soon
This is a known issue with windows for meteor : https://github.com/sdarnell/meteor/issues/7. The one on meteor's github repo might also be related. I have it too! Hopefully they sort it out soon!. Just ctrl+c to stop your server before you edit code and get it back up after you're done.
Even if you start it after this sometimes you could also get an ADDRINUSE error, which is quite frustrating.