Errors EADDRINUSE and ECONNREFUSED with script - javascript

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.

Related

MySQL Timed out when starting server

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

Error: Cannot find module "moduleIntro.js" when running "http"

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.

how to run mysql on express js in linux mint

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.

Failing to connect to mongo when deploying to Heroku

I am trying to deploy my node app to Heroku.
I have added the MLab MongoDB add on and have set the config variable
$ heroku config
=== thevoyageapp Config Vars
MONGODB_URI: mongodb://heroku_f80ngvbz:btt04p7erog80#ds.mlab.com:11/herokgvbz
And have added the process.env.MONGODB_URI to my mongo connection
const mongoose = require('mongoose');
let url = process.env.MONGODB_URI || 'mongodb://localhost/trip';
mongoose.connect(url, { useMongoClient: true });
But I still get this error:
2018-01-23T06:00:15.722831+00:00 heroku[web.1]: Starting process with command `node server/index.js`
2018-01-23T06:00:17.808211+00:00 app[web.1]: mongodb://heroku_f80ngvbz:btt04p7erog80cot3ufp1#ds.mlab.com:11/heroku_f80ngvbz
2018-01-23T06:00:17.807864+00:00 app[web.1]: listening on port 3000 ^
2018-01-23T06:00:17.835657+00:00 app[web.1]: MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
2018-01-23T06:00:17.835658+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:336:35)
2018-01-23T06:00:17.835659+00:00 app[web.1]: at emitOne (events.js:116:13)
2018-01-23T06:00:17.835663+00:00 app[web.1]: at Connection.emit (events.js:214:7)
2018-01-23T06:00:17.835660+00:00 app[web.1]: at Pool.emit (events.js:211:7)
2018-01-23T06:00:17.835661+00:00 app[web.1]: at Object.onceWrapper (events.js:317:30)
2018-01-23T06:00:17.835661+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:280:12)
2018-01-23T06:00:17.835664+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:189:49)
2018-01-23T06:00:17.835662+00:00 app[web.1]: at emitTwo (events.js:126:13)
2018-01-23T06:00:17.835664+00:00 app[web.1]: at Object.onceWrapper (events.js:315:30)
2018-01-23T06:00:17.835665+00:00 app[web.1]: at emitOne (events.js:116:13)
2018-01-23T06:00:17.835666+00:00 app[web.1]: at Socket.emit (events.js:211:7)
2018-01-23T06:00:17.835667+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:64:8)
2018-01-23T06:00:17.835668+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:138:11)
2018-01-23T06:00:17.835668+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:180:9)
2018-01-23T06:00:17.940249+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-23T06:00:17.926212+00:00 heroku[web.1]: Process exited with status 1
Any idea what could be the issue?
It is highly possible that you forget to whitelist the server IP to access MongoDB database. You can whitelist the IP at MongoDB Atlas.

Error: listen EACCES IP:80 with ExpressJS and PM2

I want host my ExpressJS (AdonisJS) application on PM2.
But, 80 port is not authorize less than 1024.
I want add HOST URL and PORT.
Error: listen EACCES IP:80
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1334:19)
at listenInCluster (net.js:1392:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
Have you tried sudo pm2 appname? You need sudo access for port 80

Categories

Resources