Playing around Microsoft's botframework, when I try to run the app.js file, which is the main file of the bot, the first time is fine, after I close the bot emulator, and all programs, and run the app.js again, this error message pops out
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3978
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Server.listen (C:\Users\yu\Documents\GitHub\BotBuilder-
Samples\Node\cards-AdaptiveCards\node_modules\restify\lib\server.js:404:32)
at Object.<anonymous> (C:\Users\yu\Documents\GitHub\BotBuilder-
Samples\Node\cards-AdaptiveCards\app.js:10:8)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
I found some solution to this, It looks like the port 3978 was taken when I run the js file for the second time, and I have to use cmd to find which task is using that port, and then kill the task.
C:\>netstat -aon|findstr 3978
so this one is taking the port, although I already closed all programs
TCP 0.0.0.0:3978 0.0.0.0:0 LISTENING 13140
TCP [::]:3978 [::]:0 LISTENING 13140
actually it is node.exe itself, it still running at background
C:\Users\yu>tasklist|findstr 13140
node.exe 13140 Console 1 42,064 K
and I need to kill it
C:\Users\yu>taskkill /f /t /im node.exe
Is there a way to not always repeat doing this when I want to run the file more than one time, it just starts to go wired today, and I mean for all different app.js files, include offical sample code. For the past one month, everything was fine, the IDE I am using is sublime text 3, node.js version is 8.9.4 lts
This is a very common issue and can be easily fixed by either of the below methods.
Try to close the process that is using your port.
netstat -tulnp | grep <port_number>
Installing the below pakcage 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
This will also persist across reboots.
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details
Either one of the solutions will work . If not then restart your system and check again.
I also got the same problem and tried many ways but finally got this ,this work well
npm install ws@3.3.2 --save-dev --save-exact
refer to this link for more clarifications
https://github.com/ionic-team/ionic-cli/issues/2922
Try specify a different port before you run the node.js application.
For example, if you have collision on port 3978, set a different port before you start the server.js:
export PORT=3979
If you are on mac
, to make sure nothing is running on the same port, do:
killall node
and restart your app.
The port you are listening to is already being listened by another process.
When I faced to this error I killed the process using Windows PowerShell (because I used Windows)
- open the windows powershell
- type
ps
and then you can get list of processes
- find the process named node, and note the Id
- type
Stop-process <Id>
I think that it is help for windows users.
Even I was also getting the error while running node server.
i.e events.js:183
throw er; // Unhandled 'error' event
^
In my case, I was getting that error because I had changed Mysql port number 3306 to 3307 while installing. I recovered from from that error by changing Mysql port number to 3306, and now its running.
I did also face the same problem. Installing of npm install ws@3.3.2 --save-dev --save-exact
was not fix this. Later I came to know that there is an another website hosted by IIS in the same port where I configured for Node JS express server. Stopping of IIS website can get rid out of this issue.
Find the process that is using the port and kill it.
Assuming the server port is 8000.
1) C:> netstat -aon | findstr 8000
This command will return the Process ID (PID).
2) C:> taskkill /F /PID 7848
This command will kill the Process by PID.
I experienced the same problem. Installing this package solved it permanently:
npm install ws@3.3.2 --save-dev --save-exact