How to fix Kotlin Reactjs tutorial error: listen EADDRINUSE - node.js

As part of this basic tutorial, I downloaded the code from this repo, and attempted to run it with the command ./gradlew run on an Ubuntu 20.04 environment.
This resulted in the following error:
> Task :browserDevelopmentRun
✖ 「wds」: Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
✖ 「wds」: Error: listen EADDRINUSE: address already in use 127.0.0.1:8080
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1503:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:8) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '127.0.0.1',
port: 8080
}
The process seems to be the only one running on this port, and attempts to get rid of any other processes using port 8080 (sudo kill -9 'sudo lsof -t -i:8080', killall node, etc...) have no effect. The conflicting processes seem to both come from within the tutorial web app.
Changing the port using a .env file also did not work. No matter what port is set (8081, 3000, 83000, etc...), there is still the error of port 8080 already being in use.
Does anyone know a solution to this issue? Thanks!

So while I didn't figure out exactly which dependency was causing this issue, on trying out a couple of the pull request on the repository, I found that this one: https://github.com/kotlin-hands-on/web-app-react-kotlin-js-gradle/pull/11 fixes the problem. Hopefully, it will be merged into the main branch soon!

Related

Getting Error while connecting mongodb to Node.js app using mongoose atlas

I was trying to connect the MongoDB atlas using mongoose but this is the error I'm getting.
[nodemon] starting `node app.js`
node:events:505
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1372:16)
at listenInCluster (node:net:1420:12)
at Server.listen (node:net:1508:7)
at Function.listen (E:\S and P Global Notes_lect\Nodetest\node_modules\express\lib\application.js:635:24)
at E:\S and P Global Notes_lect\Nodetest\app.js:11:97
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1399:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
First I thought the error was in the password encoding but I solved it then I got this one
You are most likely already running the server in the same port (3000).
Check your processes and terminate the other instance of the node app that is listening on 3000
Check your network to see if port 3000 is already in use by another application
or
Change the port of your node app to listen to another unused port and the error should go away.

Nodejs address already in use :::5000

I am trying to run a nodes app. I run node app.js. When I do, I get this error:
node:events:346
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::5000
at Server.setupListenHandle [as _listen2] (node:net:1311:16)
at listenInCluster (node:net:1359:12)
at Server.listen (node:net:1446:7)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1338:8)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::',
port: 5000
}
I spent hours looking at possible solutions online but none have worked so far. Same codebase works great on a different machine. This error happens on Mac M1 chip.
Does anybody have any idea how to fix this?
I tried finding processes running on 5000, I tried to kill them etc... nothing worked so far. I am running node 15.14.0.
I am on a M1 Chip, running macOS Monterey
How can I fix this error?
You should disable AirPlay on your mac. Because macOS Monterey started to listen to port 5000 and 8000.
System Preferences > Sharing > untick AirPlay Receiver
For macOS Ventura:
System Settings > General > disable Airplay Receiver
Lee Jeonghyun was correct. The reason why kill -9 PID would never work is because of this:
https://developer.apple.com/forums/thread/682332
Control Center on Monterey is listening on 5000 as well.
I changed the port number in my nodejs app and the app started working again.
List all process on mac:
sudo lsof -PiTCP -sTCP:LISTEN
You will see a list of process and its ports. Choose the process PID on 5000 port or any other port in the error: EADDRINUSE: address already in use...
Finally kill it if it is not an important app for you
kill -9 1234
This also happened to me after upgrading to macOS Monterey from Big Sur.
Every port that I passed to my Node app appeared to be already in use.
You need to disable AirPlay on your mac.
System Preferences > Sharing > untick AirPlay Receiver
Screenshot
Did some investigation and found that macOS Monterey is using 5000 port for Airplay-Receiver. If you really want to use the port, then disable that feature in "System Preferences->Sharing".
Below medium post helped me:
Port 5000 already in use — MacOS Monterey issue

Node Server Running on Port 80 errors with using PM2

I have an express node server running on aws ec2 instance. When I run
sudo node server.js
the server runs on port 80 and works fine when I make an http request to the server. However, when I run
sudo pm2 start server.js
I get the following error whenever I make a request
{ Error: listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1242:19)
at listenInCluster (net.js:1307:12)
at Server.listen (net.js:1395:7)
at Object.<anonymous> (/home/ubuntu/evercampus-server/server.js:19:8)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
at Module._compile (internal/modules/cjs/loader.js:816:30)
code: 'EACCES',
errno: 'EACCES',
syscall: 'listen',
address: '0.0.0.0',
port: 80 }
I tried using pm2 to run on port 5000 and it works fine.
I am very confused on why sudo node server.js works but sudo pm2 start server.js does not.
I saw on another post (Running Node app via PM2 on port 80) about running the server on port 5000 and forwarding requests from port 80 to 5000. However, I want to understand why pm2 won't work on port 80.
Because PM2 will invoke Node without sudo. Yes, PM2 will run under root but that does not necessarily mean the actual Node process will run under root also.

nodemon is crashing after several changes done in project files?

When I update the project Files I get this issue given Below:
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::4000
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 Function.listen (E:\nodejs-mysql-authentication- master\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (E:\nodejs-mysql-authentication-master\server.js:26:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
[nodemon] app crashed - waiting for file changes before starting...
I already try all this point to short out this issue given below
1.I manually stops the all node services than again I try npm start It's not worked if i change port 4001 it's work after, some time again same issue port 4001.
2.I Increase the nodemon file watcher size but still this issue not get solved.
But When I restart My PC again then nodemon is working on same port.
So How I can solve this issue, If I don't want to change my port and can't restart my PC.
Adding --signal SIGTERM to nodemon command line fixed for me. You can have more details at nodemon project # github.com
The issue occurs due to a thread still running when nodemon restarts the app, and this thread is already using the port you want to use. You can confirm this with these steps:
Make nodemon crash. You should see something like the error posted by OP
hit CTRL+c when it happens to stop nodemon
enter netstat -napt | grep [YOUR_PORT], replace [YOUR_PORT] with the port number you are using. In the OP's case it's 4000
you should get the process listening on that port. The command will return something like this:
ff#darkpc:~/dev/dp/graphql/teste1> netstat -napt | grep 4000
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::4000 :::* LISTEN 31837/node8
if you try to run nodemon again it will crash!
kill the process using your port with kill 31837 in this case 31387 is the PID of node8 as you can see above
run nodemon again and it will work.
Adding the --signal SIGTERM to nodemon command line will kill the main process and all it's threads and should fix the problem.

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.

Resources