I tried a basic beginner program in Node.Js where I wanted to use the built-in module 'http'. After executing a basic program of http.createServer(). Below is my source code.
var http = require('http');
http.createServer(function (req, res) {
res.write('Hello World!');
res.end();
}).listen(8080);
When running the code in cmd it didn't run and displayed the following error.
events.js:287
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1313:16)
at listenInCluster (net.js:1361:12)
at Server.listen (net.js:1449:7)
at Object.<anonymous> (F:\NodeJS\first app\w3schools\moduleIntro,.js:7:4)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1340:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8080
}
Ok, it's not problem in your code actually 8080 already running anywhere else so you can't run the same port number at a time so just close all running process Or you just shut down your PC and run again the problem will be resolve.
Related
So i was working on a login system with MySql. At first it worked perfectly, but after a bit of time it stopped working and now when I start it it gives me
Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (I:\Websites\backend\node_modules\mysql\lib\Connection.js:409:13)
at Object.onceWrapper (events.js:519:28)
at Socket.emit (events.js:400:28)
at Socket._onTimeout (net.js:484:8)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
--------------------
at Protocol._enqueue (I:\Websites\backend\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (I:\Websites\backend\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (I:\Websites\backend\node_modules\mysql\lib\Connection.js:116:18)
at Object.<anonymous> (I:\Websites\backend\Main.js:20:4)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true
}
What is also important to say is that I do not host the Database on my PC, I have rented a server for it. Hope that someone can help
I used to run mysql using xampp, do I have to run mysql service?
I followed this tutorial -> http://mfikri.com/en/blog/nodejs-mysql-crud
I'm confused in step #2
Server is running at port 8000
/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/index.js:23
if(err) throw err;
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1136:16)
--------------------
at Protocol._enqueue (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/node_modules/mysql/lib/Connection.js:118:18)
at Object.<anonymous> (/home/aziz/Desktop/Myprojects/backend/crud_fikri/crud-nodejs-mysql/index.js:22:6)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
It seems like the connection to your db was refused. Make sure you are using the correct database account and that it has privileges.
Also make sure to whitelist your app from db.
You need to whitelist the following ips: 127.0.0.1 and localhost
this thread can possibly be of help: node.js mysql error: ECONNREFUSED
Yes, you need a MySQL DB running. The easiest way is to install Docker on your machine, and use the official MySQL container.
I've seen a ton of conflicting answers and I want this thread to be very conclusive. I'm running a Node.js app that needs to have a server endpoint to call a google mysql database.
The SQL call I'm making in server.js should be fine, empty though. Regardless, the break point isn't at the SQL call.
There's no enforced password set up so I have those credentials set up as
...
user: 'root',
password: '',
...
and I'm currently not using the socketPort configuration option.
Respond if you need any more information about the database.
This is a full stack trace, you can see it yourself by running npm run dev
Error connecting: Error: connect ETIMEDOUTat Connection._handleConnectTimeout (C:\Users\********\Projects\security-project\security-dashboard\node_modules\mysql\lib\Connection.js:412:13)
at Object.onceWrapper (events.js:286:20)
at Socket.emit (events.js:198:13)
at Socket._onTimeout (net.js:442:8)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
--------------------
at Protocol._enqueue (C:\Users\********\Projects\security-project\security-dashboard\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\********\Projects\security-project\security-dashboard\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\*******\Projects\security-project\security-dashboard\node_modules\mysql\lib\Connection.js:119:18)
at Object.<anonymous> (C:\Users\*********\Projects\security-project\security-dashboard\database.js:26:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
[ ready ] compiled successfully
I have script from CSgo roullete.when im try run it show me this error
errno: 'ECONNREFUSED',
syscall: 'connect',
address: 'XXX.XX.XXX.XX',
port: 3306,
fatal: true }
Error: connect ECONNREFUSED XXX.XX.XXX.XX:3306
at Object.exports._errnoException (util.js:890:11)
at exports._exceptionWithHostPort (util.js:913:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)
--------------------
at Protocol._enqueue (/root/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/root/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at PoolConnection.connect (/root/node_modules/mysql/lib/Connection.js:123:18)
at Pool.getConnection (/root/node_modules/mysql/lib/Pool.js:45:23)
at query (/var/www/html/Bot/BOT/site.js:595:7)
at load (/var/www/html/Bot/BOT/site.js:607:2)
at Object.<anonymous> (/var/www/html/Bot/BOT/site.js:59:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
i have VPS with Ubuntu 15.10
#update
Now Mysql working good but if i want start this script i got this error.
[Error: listen EADDRINUSE :::8080]
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8080 }
Error: listen EADDRINUSE :::8080
at Object.exports._errnoException (util.js:890:11)
at exports._exceptionWithHostPort (util.js:913:20)
at Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Server.listen (net.js:1366:5)
at Server.listen.Server.attach (/root/node_modules/socket.io/lib/index.js:216:9)
at Timeout._onTimeout (/var/www/html/Bot/BOT/site.js:618:29)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
Most likely your mysql server is not running, or running on a different port/interface.
I am trying to use node-ar-drone package for controlling and interfacing with an AR Parrot Drone 2 but I get the following errors after connecting to the wireless network of the drone in my OSX Yosemite:
587214779:examples mona$ node png-stream.js
Connecting png stream ...
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1039:14)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.<anonymous> (/Users/mona/iotlab/armyo/node-ar-drone/examples/png-stream.js:28:8)
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)
587214779:examples mona$
I wonder what the error might be?
For more information, I have followed these tutorials:
git clone https://github.com/felixge/node-ar-drone.git
install it using this command:
npm install git://github.com/felixge/node-ar-drone.git
P.S.: I am literally running an example in the example directory and I am not changing any code.
In png-stream.js change the following lines:
server.listen(8080, function() {
console.log('Serving latest png on port 8080 ...');
});
To a different port, 8081 for instance:
server.listen(8081, function() {
console.log('Serving latest png on port 8081 ...');
});
You need sudo/admin priviliges on your machine to run it on port 8080 or any port used. You will need to start with sudo on linux.
sudo npm start
did the trick on my ubuntu and react application