Failing to connect to mongo when deploying to Heroku - javascript

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.

Related

Trouble hosting project via Heroku

When I start my project via Heroku I am getting an error saying that "app" is not defined. I have logged "app" and get data back so I do not know why this is happening. Has anyone had this issue before? Here are the errors and the code:
State changed from starting to crashed
2021-05-05T22:16:42.626715+00:00 app[web.1]: /app/listen.js:3
2021-05-05T22:16:42.626744+00:00 app[web.1]: app.listen(PORT, () => console.log(`Listening on ${PORT}...`));
2021-05-05T22:16:42.626745+00:00 app[web.1]: ^
2021-05-05T22:16:42.626745+00:00 app[web.1]:
2021-05-05T22:16:42.626751+00:00 app[web.1]: ReferenceError: app is not defined
2021-05-05T22:16:42.626752+00:00 app[web.1]: at Object.<anonymous> (/app/listen.js:3:1)
2021-05-05T22:16:42.626752+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2021-05-05T22:16:42.626758+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-05-05T22:16:42.626758+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-05-05T22:16:42.626759+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-05-05T22:16:42.626764+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
2021-05-05T22:16:42.626765+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-05-05T22:16:42.652119+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-05-05T22:16:42.652547+00:00 app[web.1]: npm ERR! errno 1
2021-05-05T22:16:42.661700+00:00 app[web.1]: npm ERR! be-nc-news#1.0.0 start: `node listen.js`
2021-05-05T22:16:42.661926+00:00 app[web.1]: npm ERR! Exit status 1
2021-05-05T22:16:42.662168+00:00 app[web.1]: npm ERR!
2021-05-05T22:16:42.662387+00:00 app[web.1]: npm ERR! Failed at the be-nc-news#1.0.0 start script.
2021-05-05T22:16:42.662587+00:00 app[web.1]: npm ERR! This is probably not a problem with npm.
app.js:
const express = require("express");
const apiRouter = require("./routes/apiRouter");
const app = express();
const {
handlePsqlErrors,
handleServerErrors,
} = require("./errorHandlingFunctions/errorFunctions");
app.use(express.json());
app.use("/api", apiRouter);
app.use(handlePsqlErrors);
app.use(handleServerErrors);
module.exports = app;
listen.js:
const app = require("./app");
console.log(app);
const { PORT = 9090 } = process.env;
app.listen(PORT, () => console.log(`Listening on port ${PORT}...`));

Pupeeteer heroku buildpack exiting the lunch statement on heroku

This is the error it gives me when I deploy to heroku
It is says that I should check the file "localScrape.js" on line 11 column 21.
I went and included a try/catch block to work my way around it but it is persistently giving me the same error could.
2020-10-02T14:06:40.613205+00:00 app[web.1]: > node index
2020-10-02T14:06:40.613205+00:00 app[web.1]:
2020-10-02T14:06:41.196275+00:00 app[web.1]: Innitializing.....
2020-10-02T14:06:41.197532+00:00 app[web.1]: Starting the server....
2020-10-02T14:06:41.197609+00:00 app[web.1]: Server started..
2020-10-02T14:06:41.197667+00:00 app[web.1]: Server Listening on port 4000
2020-10-02T14:06:41.950485+00:00 app[web.1]: DB Connected successfully
2020-10-02T14:06:47.624092+00:00 app[web.1]: events.js:292
2020-10-02T14:06:47.624104+00:00 app[web.1]: throw er; // Unhandled 'error' event
2020-10-02T14:06:47.624105+00:00 app[web.1]: ^
2020-10-02T14:06:47.624105+00:00 app[web.1]:
2020-10-02T14:06:47.624106+00:00 app[web.1]: Error: read ENOTCONN
2020-10-02T14:06:47.624106+00:00 app[web.1]: at tryReadStart (net.js:573:20)
2020-10-02T14:06:47.624107+00:00 app[web.1]: at Socket._read (net.js:584:5)
2020-10-02T14:06:47.624107+00:00 app[web.1]: at Socket.Readable.read (_stream_readable.js:467:10)
2020-10-02T14:06:47.624108+00:00 app[web.1]: at Socket.read (net.js:624:39)
2020-10-02T14:06:47.624108+00:00 app[web.1]: at new Socket (net.js:376:12)
2020-10-02T14:06:47.624109+00:00 app[web.1]: at Object.Socket (net.js:267:41)
2020-10-02T14:06:47.624109+00:00 app[web.1]: at createSocket (internal/child_process.js:314:14)
2020-10-02T14:06:47.624109+00:00 app[web.1]: at ChildProcess.spawn (internal/child_process.js:437:23)
2020-10-02T14:06:47.624110+00:00 app[web.1]: at Object.spawn (child_process.js:548:9)
2020-10-02T14:06:47.624110+00:00 app[web.1]: at BrowserRunner.start (/app/node_modules/puppeteer/lib/launcher/BrowserRunner.js:51:34)
2020-10-02T14:06:47.624111+00:00 app[web.1]: at ChromeLauncher.launch (/app/node_modules/puppeteer/lib/Launcher.js:64:16)
2020-10-02T14:06:47.624111+00:00 app[web.1]: at async localScrape (/app/Scraper/localScrape.js:11:21)
2020-10-02T14:06:47.624111+00:00 app[web.1]: at async doScraping (/app/index.js:20:3)
2020-10-02T14:06:47.624112+00:00 app[web.1]: Emitted 'error' event on Socket instance at:
2020-10-02T14:06:47.624112+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:92:8)
2020-10-02T14:06:47.624112+00:00 app[web.1]: at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
2020-10-02T14:06:47.624113+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-10-02T14:06:47.624113+00:00 app[web.1]: errno: 'ENOTCONN',
2020-10-02T14:06:47.624114+00:00 app[web.1]: code: 'ENOTCONN',
2020-10-02T14:06:47.624114+00:00 app[web.1]: syscall: 'read'
2020-10-02T14:06:47.624114+00:00 app[web.1]: }
2020-10-02T14:06:47.643941+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-10-02T14:06:47.644301+00:00 app[web.1]: npm ERR! errno 1
2020-10-02T14:06:47.648553+00:00 app[web.1]: npm ERR! scraping-script-for-news#1.0.0 start: `node index`
2020-10-02T14:06:47.648770+00:00 app[web.1]: npm ERR! Exit status 1
2020-10-02T14:06:47.649014+00:00 app[web.1]: npm ERR!
2020-10-02T14:06:47.649222+00:00 app[web.1]: npm ERR! Failed at the scraping-script-for-news#1.0.0 start script.
2020-10-02T14:06:47.649428+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-10-02T14:06:49.194170+00:00 app[web.1]:
2020-10-02T14:06:49.194363+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-10-02T14:06:49.194480+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-10-02T14_06_47_651Z-debug.log
2020-10-02T14:06:49.249822+00:00 heroku[web.1]: Process exited with status 1
2020-10-02T14:06:49.281443+00:00 heroku[web.1]: State changed from starting to crashed```

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.

how to fix heroku error while deploying an expressjs app?

I've been trying to fix a heroku api but I keep getting an error which I cant fix. The app is not even running, it goes straight to the error. It was working until I recently made an update to the api.
The error is shown as
2019-10-18T21:40:06.936984+00:00 app[web.1]: at Function.Module._load
(internal/modules/cjs/loader.js:585:3)
2019-10-18T21:40:06.936986+00:00 app[web.1]: at Module.require
(internal/modules/cjs/loader.js:692:17)
2019-10-18T21:40:06.936988+00:00 app[web.1]: at require
(internal/modules/cjs/helpers.js:25:18)
2019-10-18T21:40:06.936989+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api.js:7:16)
2019-10-18T21:40:06.936991+00:00 app[web.1]: at Module._compile
(internal/modules/cjs/loader.js:778:30)
2019-10-18T21:40:06.944691+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-10-18T21:40:06.945081+00:00 app[web.1]: npm ERR! errno 1
2019-10-18T21:40:06.946204+00:00 app[web.1]: npm ERR! quickJobs-api#1.0.0 start: `node
server.js`
2019-10-18T21:40:06.946319+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T21:40:06.946542+00:00 app[web.1]: npm ERR!
2019-10-18T21:40:06.946663+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api#1.0.0 start script.
2019-10-18T21:40:06.946779+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T21:40:06.953214+00:00 app[web.1]:
2019-10-18T21:40:06.953367+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T21:40:06.953452+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-10-18T21_40_06_948Z-debug.log
2019-10-18T21:40:07.008783+00:00 heroku[web.1]: Process exited with status 1
2019-10-18T21:40:24.571093+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:16.977483+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quickjobsapi.herokuapp.com request_id=a50a5c3e-7152-4ce1-942f-df572188531b fwd="63.143.196.162" dyno= connect= serv
ice= status=503 bytes= protocol=https
2019-10-18T22:05:17.639126+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quickjobsapi.herokuapp.com request_id=405f9fd7-ae38-478e-b182-7e5306ab0fa6 fwd="63.143.196.162" dyno= co
nnect= service= status=503 bytes= protocol=https
2019-10-18T22:05:48.086732+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:50.688489+00:00 heroku[web.1]: Starting process with command `npm start`
2019-10-18T22:05:53.119843+00:00 app[web.1]:
2019-10-18T22:05:53.119869+00:00 app[web.1]: > quickJobs-api#1.0.0 start /app
2019-10-18T22:05:53.119871+00:00 app[web.1]: > node server.js
2019-10-18T22:05:53.119872+00:00 app[web.1]:
2019-10-18T22:05:54.001916+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-18T22:05:53.873724+00:00 app[web.1]: internal/modules/cjs/loader.js:807
2019-10-18T22:05:53.873754+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2019-10-18T22:05:53.873756+00:00 app[web.1]: ^
2019-10-18T22:05:53.873758+00:00 app[web.1]:
2019-10-18T22:05:53.873760+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2019-10-18T22:05:53.873761+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
2019-10-18T22:05:53.873763+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:05:53.873765+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:05:53.873767+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:05:53.873768+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:05:53.873770+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:05:53.873771+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2019-10-18T22:05:53.873773+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:05:53.882321+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-10-18T22:05:53.882732+00:00 app[web.1]: npm ERR! errno 1
2019-10-18T22:05:53.883970+00:00 app[web.1]: npm ERR! quickJobs-api#1.0.0 start: `node server.js`
2019-10-18T22:05:53.884082+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T22:05:53.884277+00:00 app[web.1]: npm ERR!
2019-10-18T22:05:53.884398+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api#1.0.0 start script.
2019-10-18T22:05:53.884514+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T22:05:53.914312+00:00 app[web.1]:
2019-10-18T22:05:53.914489+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T22:05:53.914584+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-10-18T22_05_53_885Z-debug.log
2019-10-18T22:05:54.019964+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:53.977749+00:00 heroku[web.1]: Process exited with status 1
2019-10-18T22:05:57.322980+00:00 heroku[web.1]: Starting process with command `npm start`
2019-10-18T22:06:00.008642+00:00 app[web.1]:
2019-10-18T22:06:00.008674+00:00 app[web.1]: > quickJobs-api#1.0.0 start /app
2019-10-18T22:06:00.008676+00:00 app[web.1]: > node server.js
2019-10-18T22:06:00.008678+00:00 app[web.1]:
2019-10-18T22:06:00.907169+00:00 app[web.1]: internal/modules/cjs/loader.js:807
2019-10-18T22:06:00.907208+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2019-10-18T22:06:00.907211+00:00 app[web.1]: ^
2019-10-18T22:06:00.907214+00:00 app[web.1]:
2019-10-18T22:06:00.907216+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2019-10-18T22:06:00.907218+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
2019-10-18T22:06:00.907220+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:06:00.907223+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:06:00.907225+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:06:00.907228+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:06:00.907229+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:06:00.907232+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2019-10-18T22:06:00.907234+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:06:00.907235+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2019-10-18T22:06:00.907238+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:06:00.907242+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:06:00.907244+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:06:00.907247+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:06:00.907249+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:06:00.907251+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api.js:7:16)
2019-10-18T22:06:00.907253+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:06:00.925298+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-10-18T22:06:00.925759+00:00 app[web.1]: npm ERR! errno 1
2019-10-18T22:06:00.926956+00:00 app[web.1]: npm ERR! quickJobs-api#1.0.0 start: `node server.js`
2019-10-18T22:06:00.927125+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T22:06:00.927387+00:00 app[web.1]: npm ERR!
2019-10-18T22:06:00.927644+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api#1.0.0 start script.
2019-10-18T22:06:00.927832+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T22:06:00.942491+00:00 app[web.1]:
2019-10-18T22:06:00.942496+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T22:06:00.942498+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-10-18T22_06_00_929Z-debug.log
2019-10-18T22:06:01.013650+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-18T22:06:00.991627+00:00 heroku[web.1]: Process exited with status 1
Git
2019-10-18T22:06:00.778487+00:00 heroku[web.1]: State changed from starting to up
2019-10-18T22:06:01.574620+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quickjobsapi.herokuapp.com request_id=e500ac9e-cc2f-4cde-9f91-8424f36c57f2 fwd="63.143.196.162" dyno= connect= serv
ice= status=503 bytes= protocol=https
2019-10-18T22:06:02.282334+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quickjobsapi.herokuapp.com request_id=38013505-dfbc-4e8a-90e4-e55077f9b467 fwd="63.143.196.162" dyno= co
nnect= service= status=503 bytes= protocol=https
My server.js file has
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const app = express()
app.use(cors())
//const PORT = process.env.PORT || 3000;
app.listen(process.env.PORT || 3000,function(){
console.log('server has been started')
})
app.use(bodyParser.json({limit: "500mb"}));
app.use(bodyParser.urlencoded({limit: "500mb", extended: true, parameterLimit:50000}));
app.use('/api',require('./routes/api'))
The other files are just the api and the schema for mongodb.
Please help
I see that there is a bcrypt related error. Are you using different Node.js version on your local dev and your prod? If yes then try to ignore the package manager lock file yarn.lock or package-lock.json.
lock file usually "hold" version specific dependency, in some case package with native dependency like bcrypt can cause some issue.

Errors EADDRINUSE and ECONNREFUSED with script

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.

Categories

Resources