Heroku NodeJS - Error: Cannot find module './prod.json' - json

First time pushing this app to heroku (and first time doing a NodeJS API), and when the app tries to start, I get this error in heroku's logs. It works fine in dev - what am I missing?
I have a file: config/prod.json
And in package.json
"scripts": {
"start": "export NODE_ENV=prod && nodemon ./index.js",
"windev": "set NODE_ENV=dev && nodemon ./index.js",
"dev": "export NODE_ENV=dev && nodemon ./index.js",
"prod": "export NODE_ENV=prod && nodemon ./index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Full output:
2018-01-05T21:40:37.628592+00:00 app[web.1]: > export NODE_ENV=prod && nodemon ./index.js
2018-01-05T21:40:37.628593+00:00 app[web.1]:
2018-01-05T21:40:39.610679+00:00 app[web.1]: [nodemon] 1.12.5
2018-01-05T21:40:39.620087+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2018-01-05T21:40:39.620443+00:00 app[web.1]: [nodemon] watching: *.*
2018-01-05T21:40:39.621169+00:00 app[web.1]: [nodemon] starting `node ./index.js`
2018-01-05T21:40:42.769518+00:00 app[web.1]: module.js:540
2018-01-05T21:40:42.769527+00:00 app[web.1]: throw err;
2018-01-05T21:40:42.769528+00:00 app[web.1]: ^
2018-01-05T21:40:42.769528+00:00 app[web.1]:
2018-01-05T21:40:42.769529+00:00 app[web.1]: Error: Cannot find module './prod.json'
2018-01-05T21:40:42.769555+00:00 app[web.1]: at Module.require (module.js:587:17)
2018-01-05T21:40:42.769553+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:538:15)
2018-01-05T21:40:42.769554+00:00 app[web.1]: at Function.Module._load (module.js:468:25)
2018-01-05T21:40:42.769559+00:00 app[web.1]: at Module._compile (module.js:643:30)
2018-01-05T21:40:42.769556+00:00 app[web.1]: at Object.<anonymous> (/app/config/config.js:2:18)
2018-01-05T21:40:42.769556+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-01-05T21:40:42.769560+00:00 app[web.1]: at Module.load (module.js:556:32)
2018-01-05T21:40:42.769560+00:00 app[web.1]: at Object.Module._extensions..js (module.js:654:10)
2018-01-05T21:40:42.769561+00:00 app[web.1]: at Function.Module._load (module.js:491:3)
2018-01-05T21:40:42.769561+00:00 app[web.1]: at tryModuleLoad (module.js:499:12)
2018-01-05T21:40:42.769563+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-01-05T21:40:42.769563+00:00 app[web.1]: at Module.require (module.js:587:17)
2018-01-05T21:40:42.769564+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:6:16)
2018-01-05T21:40:42.769565+00:00 app[web.1]: at Module._compile (module.js:643:30)
2018-01-05T21:40:42.769565+00:00 app[web.1]: at Object.Module._extensions..js (module.js:654:10)
2018-01-05T21:40:42.769566+00:00 app[web.1]: at Module.load (module.js:556:32)
2018-01-05T21:40:42.769568+00:00 app[web.1]: at tryModuleLoad (module.js:499:12)
2018-01-05T21:40:42.769569+00:00 app[web.1]: at Function.Module._load (module.js:491:3)
2018-01-05T21:40:42.769570+00:00 app[web.1]: at Function.Module.runMain (module.js:684:10)
2018-01-05T21:40:42.769571+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-01-05T21:40:42.769572+00:00 app[web.1]: at bootstrap_node.js:608:3
2018-01-05T21:40:42.827358+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...

Related

Face problem when deploying mern application to heroku

I face problem when I opened the app deployed on heroku
2022-06-25T03:52:33.123405+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-06-25T03:52:33.123406+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-06-25T03:52:33.123406+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2022-06-25T03:52:33.123406+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-06-25T03:52:33.123407+00:00 app[web.1]: requireStack: [ '/app/routes/authenticationRoute.js', '/app/server.js' ]
2022-06-25T03:52:33.123407+00:00 app[web.1]: }

'Node Api using mysql' deployed on heroku crashes after some time Interval

I have created a Node API using MySQL and deployed it on Heroku. But after every 20-25 minutes it shows 'Application error' and I have to do 'Heroku restart' again to fetch data from API. My API calls work fine when runs on localhost:port_no
Heroku Logs
>2021-06-26T04:15:47.965652+00:00 heroku[web.1]: State changed from starting to up
2021-06-26T04:20:47.759660+00:00 app[web.1]: events.js:353
2021-06-26T04:20:47.759669+00:00 app[web.1]: throw er; // Unhandled 'error' event
2021-06-26T04:20:47.759670+00:00 app[web.1]: ^
2021-06-26T04:20:47.759670+00:00 app[web.1]:
2021-06-26T04:20:47.759670+00:00 app[web.1]: Error: Connection lost: The server closed the connection.
2021-06-26T04:20:47.759671+00:00 app[web.1]: at Protocol.end (/app/node_modules/mysql/lib/protocol/Protocol.js:112:13)
2021-06-26T04:20:47.759672+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:94:28)
2021-06-26T04:20:47.759672+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:526:10)
2021-06-26T04:20:47.759673+00:00 app[web.1]: at Socket.emit (events.js:388:22)
2021-06-26T04:20:47.759673+00:00 app[web.1]: at endReadableNT (internal/streams/readable.js:1336:12)
2021-06-26T04:20:47.759674+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:82:21)
2021-06-26T04:20:47.759674+00:00 app[web.1]: Emitted 'error' event on Connection instance at:
2021-06-26T04:20:47.759676+00:00 app[web.1]: at Connection._handleProtocolError (/app/node_modules/mysql/lib/Connection.js:423:8)
2021-06-26T04:20:47.759677+00:00 app[web.1]: at Protocol.emit (events.js:376:20)
2021-06-26T04:20:47.759678+00:00 app[web.1]: at Protocol._delegateError (/app/node_modules/mysql/lib/protocol/Protocol.js:398:10)
2021-06-26T04:20:47.759678+00:00 app[web.1]: at Protocol.end (/app/node_modules/mysql/lib/protocol/Protocol.js:116:8)
2021-06-26T04:20:47.759679+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:94:28)
2021-06-26T04:20:47.759679+00:00 app[web.1]: [... lines matching original stack trace ...]
2021-06-26T04:20:47.759679+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:82:21) {
2021-06-26T04:20:47.759680+00:00 app[web.1]: fatal: true,
2021-06-26T04:20:47.759680+00:00 app[web.1]: code: 'PROTOCOL_CONNECTION_LOST'
2021-06-26T04:20:47.759681+00:00 app[web.1]: }
2021-06-26T04:20:47.817878+00:00 heroku[web.1]: Process exited with status 1
2021-06-26T04:20:47.876488+00:00 heroku[web.1]: State changed from up to crashed
My connection.js file
const mysql = require('mysql');
var sqlConnection = mysql.createConnection({
host: ##,
user:##,
password: ##,
database: ##,
multipleStatements: true
});
sqlConnection.connect((err) => {
if (!err) {
console.log("Connected");
} else {
console.log("Connection Failed");
}
})
module.exports = sqlConnection;
```

My node.js App works locally but does not work on Heroku gives "application error". The log tail is like this. Can you help me fix this?

This is the Heroku logs tail:
remote: https://desolate-temple-28640.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/desolate-temple-28640.git
132ab25..24b7d35 master -> master
Bilals-MacBook-Air:Eat-the-burger bilalsarimeseli$ heroku logs --tail
2020-03-05T04:29:51.676106+00:00 app[web.1]:
2020-03-05T04:29:51.676125+00:00 app[web.1]: > burger#1.0.0 start /app
2020-03-05T04:29:51.676125+00:00 app[web.1]: > node server.js
2020-03-05T04:29:51.676125+00:00 app[web.1]:
2020-03-05T04:29:51.929460+00:00 app[web.1]: Server listening on: http://localhost:5967
2020-03-05T04:29:51.932815+00:00 app[web.1]: error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
2020-03-05T04:29:51.932816+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
2020-03-05T04:29:51.932817+00:00 app[web.1]: --------------------
2020-03-05T04:29:51.932817+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
2020-03-05T04:29:51.932817+00:00 app[web.1]: at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
2020-03-05T04:29:51.932818+00:00 app[web.1]: at Connection.connect (/app/node_modules/mysql/lib/Connection.js:119:18)
2020-03-05T04:29:51.932818+00:00 app[web.1]: at Object. (/app/config/connection.js:16:12)
2020-03-05T04:29:51.932818+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-05T04:29:51.932819+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-05T04:29:51.932819+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-05T04:29:51.932819+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-05T04:29:51.932819+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-05T04:29:51.932820+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-05T04:29:53.272983+00:00 heroku[web.1]: State changed from starting to up
2020-03-05T05:04:18.124007+00:00 heroku[web.1]: Idling
2020-03-05T05:04:18.127663+00:00 heroku[web.1]: State changed from up to down
2020-03-05T05:04:18.993332+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-03-05T05:04:19.070341+00:00 heroku[web.1]: Process exited with status 143
2020-03-05T11:10:26.000000+00:00 app[api]: Build started by user bilalsarimeseli#gmail.com
2020-03-05T11:10:40.838353+00:00 heroku[web.1]: State changed from down to starting
2020-03-05T11:10:40.648875+00:00 app[api]: Deploy 24b7d357 by user bilalsarimeseli#gmail.com
2020-03-05T11:10:42.830384+00:00 heroku[web.1]: Starting process with command `npm start`
2020-03-05T11:10:40.648875+00:00 app[api]: Release v10 created by user bilalsarimeseli#gmail.com
2020-03-05T11:10:41.000000+00:00 app[api]: Build succeeded
2020-03-05T11:10:44.751738+00:00 app[web.1]:
2020-03-05T11:10:44.751800+00:00 app[web.1]: > burger#1.0.0 start /app
2020-03-05T11:10:44.751801+00:00 app[web.1]: > node server.js
2020-03-05T11:10:44.751806+00:00 app[web.1]:
2020-03-05T11:10:44.985822+00:00 app[web.1]: Server listening on: http://localhost:58632
2020-03-05T11:10:44.989700+00:00 app[web.1]: error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
2020-03-05T11:10:44.989705+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
2020-03-05T11:10:44.989706+00:00 app[web.1]: --------------------
2020-03-05T11:10:44.989709+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
2020-03-05T11:10:44.989710+00:00 app[web.1]: at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
2020-03-05T11:10:44.989710+00:00 app[web.1]: at Connection.connect (/app/node_modules/mysql/lib/Connection.js:119:18)
2020-03-05T11:10:44.989710+00:00 app[web.1]: at Object. (/app/config/connection.js:16:12)
2020-03-05T11:10:44.989710+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-05T11:10:44.989711+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-05T11:10:44.989711+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-05T11:10:44.989711+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-05T11:10:44.989711+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-05T11:10:44.989712+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-05T11:10:45.456540+00:00 heroku[web.1]: State changed from starting to up
2020-03-05T11:11:02.583806+00:00 app[web.1]: /app/config/orm.js:41
2020-03-05T11:11:02.583841+00:00 app[web.1]: throw err;
2020-03-05T11:11:02.583841+00:00 app[web.1]: ^
2020-03-05T11:11:02.583843+00:00 app[web.1]:
2020-03-05T11:11:02.583845+00:00 app[web.1]: Error: Cannot enqueue Query after fatal error.
2020-03-05T11:11:02.583846+00:00 app[web.1]: at Protocol._validateEnqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:212:16)
2020-03-05T11:11:02.583846+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:138:13)
2020-03-05T11:11:02.583848+00:00 app[web.1]: at Connection.query (/app/node_modules/mysql/lib/Connection.js:201:25)
2020-03-05T11:11:02.583848+00:00 app[web.1]: at Object.selectAll (/app/config/orm.js:39:20)
2020-03-05T11:11:02.583849+00:00 app[web.1]: at Object.selectAll (/app/models/burger.js:7:13)
2020-03-05T11:11:02.583849+00:00 app[web.1]: at /app/controller/burgers_controller.js:10:12
2020-03-05T11:11:02.583849+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-05T11:11:02.583850+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-03-05T11:11:02.583850+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2020-03-05T11:11:02.583850+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) {
2020-03-05T11:11:02.583851+00:00 app[web.1]: code: 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR',
2020-03-05T11:11:02.583851+00:00 app[web.1]: fatal: false
2020-03-05T11:11:02.583851+00:00 app[web.1]: }
2020-03-05T11:11:02.591344+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-03-05T11:11:02.591569+00:00 app[web.1]: npm ERR! errno 1
2020-03-05T11:11:02.592540+00:00 app[web.1]: npm ERR! burger#1.0.0 start: `node server.js`
2020-03-05T11:11:02.592651+00:00 app[web.1]: npm ERR! Exit status 1
2020-03-05T11:11:02.592779+00:00 app[web.1]: npm ERR!
2020-03-05T11:11:02.592869+00:00 app[web.1]: npm ERR! Failed at the burger#1.0.0 start script.
2020-03-05T11:11:02.592974+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-03-05T11:11:02.596948+00:00 app[web.1]:
2020-03-05T11:11:02.597121+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-03-05T11:11:02.597200+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-03-05T11_11_02_593Z-debug.log
2020-03-05T11:11:02.659995+00:00 heroku[web.1]: State changed from up to crashed
2020-03-05T11:11:02.663569+00:00 heroku[web.1]: State changed from crashed to starting
2020-03-05T11:11:02.591268+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=desolate-temple-28640.herokuapp.com request_id=babd3c58-db4a-4333-8b8c-1d3b6c180144 fwd="73.170.10.17" dyno=web.1 connect=1ms service=15ms status=503 bytes=0 protocol=https
2020-03-05T11:11:02.640946+00:00 heroku[web.1]: Process exited with status 1
2020-03-05T11:11:04.780991+00:00 heroku[web.1]: Starting process with command `npm start`
2020-03-05T11:11:06.928183+00:00 app[web.1]:
2020-03-05T11:11:06.928199+00:00 app[web.1]: > burger#1.0.0 start /app
2020-03-05T11:11:06.928199+00:00 app[web.1]: > node server.js
2020-03-05T11:11:06.928200+00:00 app[web.1]:
2020-03-05T11:11:07.188672+00:00 app[web.1]: Server listening on: http://localhost:23612
2020-03-05T11:11:07.192422+00:00 app[web.1]: error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
2020-03-05T11:11:07.192422+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
2020-03-05T11:11:07.192423+00:00 app[web.1]: --------------------
2020-03-05T11:11:07.192423+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
2020-03-05T11:11:07.192424+00:00 app[web.1]: at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
2020-03-05T11:11:07.192424+00:00 app[web.1]: at Connection.connect (/app/node_modules/mysql/lib/Connection.js:119:18)
2020-03-05T11:11:07.192424+00:00 app[web.1]: at Object. (/app/config/connection.js:16:12)
2020-03-05T11:11:07.192425+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-05T11:11:07.192425+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-05T11:11:07.192425+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-05T11:11:07.192426+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-05T11:11:07.192426+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-05T11:11:07.192426+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-05T11:11:07.594141+00:00 heroku[web.1]: State changed from starting to up
2020-03-05T11:15:26.050243+00:00 app[web.1]: /app/config/orm.js:41
2020-03-05T11:15:26.050267+00:00 app[web.1]: throw err;
2020-03-05T11:15:26.050267+00:00 app[web.1]: ^
2020-03-05T11:15:26.050268+00:00 app[web.1]:
2020-03-05T11:15:26.050270+00:00 app[web.1]: Error: Cannot enqueue Query after fatal error.
2020-03-05T11:15:26.050272+00:00 app[web.1]: at Protocol._validateEnqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:212:16)
2020-03-05T11:15:26.050272+00:00 app[web.1]: at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:138:13)
2020-03-05T11:15:26.050273+00:00 app[web.1]: at Connection.query (/app/node_modules/mysql/lib/Connection.js:201:25)
2020-03-05T11:15:26.050274+00:00 app[web.1]: at Object.selectAll (/app/config/orm.js:39:20)
2020-03-05T11:15:26.050274+00:00 app[web.1]: at Object.selectAll (/app/models/burger.js:7:13)
2020-03-05T11:15:26.050275+00:00 app[web.1]: at /app/controller/burgers_controller.js:10:12
2020-03-05T11:15:26.050275+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2020-03-05T11:15:26.050275+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:137:13)
2020-03-05T11:15:26.050276+00:00 app[web.1]: at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2020-03-05T11:15:26.050276+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) {
2020-03-05T11:15:26.050277+00:00 app[web.1]: code: 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR',
2020-03-05T11:15:26.050277+00:00 app[web.1]: fatal: false
2020-03-05T11:15:26.050277+00:00 app[web.1]: }
2020-03-05T11:15:26.059015+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-03-05T11:15:26.059397+00:00 app[web.1]: npm ERR! errno 1
2020-03-05T11:15:26.061003+00:00 app[web.1]: npm ERR! burger#1.0.0 start: `node server.js`
2020-03-05T11:15:26.061232+00:00 app[web.1]: npm ERR! Exit status 1
2020-03-05T11:15:26.061464+00:00 app[web.1]: npm ERR!
2020-03-05T11:15:26.061676+00:00 app[web.1]: npm ERR! Failed at the burger#1.0.0 start script.
2020-03-05T11:15:26.061857+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-03-05T11:15:26.069984+00:00 app[web.1]:
2020-03-05T11:15:26.070271+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-03-05T11:15:26.070400+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-03-05T11_15_26_062Z-debug.log
2020-03-05T11:15:26.165120+00:00 heroku[web.1]: State changed from up to crashed
2020-03-05T11:15:26.144397+00:00 heroku[web.1]: Process exited with status 1
2020-03-05T11:15:26.058348+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=desolate-temple-28640.herokuapp.com request_id=bba9be1c-a0a8-4187-9854-8f1adb4aef14 fwd="73.170.10.17" dyno=web.1 connect=0ms service=18ms status=503 bytes=0 protocol=https
2020-03-05T04:29:51.929460+00:00 app[web.1]: Server listening on: http://localhost:5967
2020-03-05T04:29:51.932815+00:00 app[web.1]: error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
I assume that you did bind your port to the environment variable $PORT which was supplied by Heroku. I assume that port is the 5967. Your program is trying to access 3306. You probably defined this port somewhere. This is on Heroku not possible.
Heroku only allows you to bind to a single port with the port number decided by Heroku.
2020-03-05T04:29:51.929460+00:00 app[web.1]: Server listening on: http://localhost:5967
2020-03-05T04:29:51.932815+00:00 app[web.1]: error connecting: Error: connect ECONNREFUSED 127.0.0.1:3306
You got an Error. Because your server tries to connect a 3306 PORT
But in your server Listening to a port 5967. simple change a PORT Number in own code .env file. Define a like
E.g.HOST=5967 in the .env file

app not deploying to heroku

I am having a problem with deploying my app on heroku. I am stuck and cannot find the answer. I have went through the heroku troubleshooting and deployment procedures. I have been trying for 3 days. I have rewritten my env file numerous times and every time I do, it doesn't work on localhost. I have MONGOD and NODEMON running. I reverted back to the original and it is working. But still will not deploy on heroku. Thanks in advance.
Here is what my env.js looks like
module.exports = {
db: process.env.MONGODB_URI || 'mongodb://localhost/sailcast',
port: process.env.PORT || 3000
}
package.json
"scripts": {
"start": "node index.js",
"postinstall": "gulp default"
},
"dependencies": {
"bcrypt": "^2.0.1",
"bluebird": "^3.5.1",
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"express-ejs-layouts": "^2.4.0",
"express-flash": "0.0.2",
"express-session": "^1.15.6",
"express-sessions": "^1.0.6",
"express-static": "^1.2.5",
"forever": "^0.15.3",
"method-override": "^2.3.10",
"mongoose": "^5.1.5",
"morgan": "^1.9.0",
"nodemon": "^1.17.5",
"passport": "^0.4.0",
"request": "^2.87.0",
"request-promise": "^4.2.2",
"yarn": "^1.7.0",
"yarn.lock": "0.0.1-security"
},
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.1",
"gulp-clean-css": "^3.9.4",
"gulp-plumber": "^1.2.0",
"gulp-sass": "^4.0.1",
"gulp-uglify": "^3.0.0"
}
Here are the heroku logs. I can't figure out the error. just keep getting application error
2018-06-16T02:00:26.831441+00:00 app[web.1]: npm ERR! sailcast#1.0.0
start: `node index.js`
2018-06-16T02:00:26.831595+00:00 app[web.1]: npm ERR! Exit status 1
2018-06-16T02:00:26.831982+00:00 app[web.1]: npm ERR! Failed at the
sailcast#1.0.0 start script.
2018-06-16T02:00:26.831821+00:00 app[web.1]: npm ERR!
2018-06-16T02:00:26.832134+00:00 app[web.1]: npm ERR! This is probably
not a problem with npm. There is likely additional logging output above.
2018-06-16T02:00:26.839530+00:00 app[web.1]:
2018-06-16T02:00:26.839805+00:00 app[web.1]: npm ERR! A complete log of
this run can be found in:
2018-06-16T02:00:26.839898+00:00 app[web.1]: npm ERR!
/app/.npm/_logs/2018-06-16T02_00_26_833Z-debug.log
2018-06-16T02:00:26.898270+00:00 heroku[web.1]: Process exited with
status 1
2018-06-16T02:00:27.233835+00:00 heroku[web.1]: State changed from
starting to crashed
2018-06-16T05:23:18.892587+00:00 heroku[web.1]: State changed from
crashed to starting
2018-06-16T05:23:22.696724+00:00 heroku[web.1]: Starting process with
command `npm start`
2018-06-16T05:23:24.791728+00:00 app[web.1]:
2018-06-16T05:23:24.791759+00:00 app[web.1]: > sailcast#1.0.0 start /app
2018-06-16T05:23:24.791761+00:00 app[web.1]: > node index.js
2018-06-16T05:23:24.791762+00:00 app[web.1]:
2018-06-16T05:23:25.449215+00:00 app[web.1]: module.js:681
2018-06-16T05:23:25.449238+00:00 app[web.1]: return
process.dlopen(module, path._makeLong(filename));
2018-06-16T05:23:25.449240+00:00 app[web.1]: ^
2018-06-16T05:23:25.449242+00:00 app[web.1]:
2018-06-16T05:23:25.449244+00:00 app[web.1]: Error:
/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2018-06-16T05:23:25.449247+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T05:23:25.449245+00:00 app[web.1]: at
Object.Module._extensions..node (module.js:681:18)
2018-06-16T05:23:25.449249+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T05:23:25.449250+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T05:23:25.449252+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T05:23:25.449253+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T05:23:25.449255+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/bcrypt/bcrypt.js:6:16)
2018-06-16T05:23:25.449257+00:00 app[web.1]: at Module._compile
(module.js:652:30)
2018-06-16T05:23:25.449258+00:00 app[web.1]: at
Object.Module._extensions..js (module.js:663:10)
2018-06-16T05:23:25.449260+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T05:23:25.449261+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T05:23:25.449263+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T05:23:25.449264+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T05:23:25.449266+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T05:23:25.449267+00:00 app[web.1]: at Object.<anonymous>
(/app/models/user.js:2:16)
2018-06-16T05:23:25.449269+00:00 app[web.1]: at Module._compile
(module.js:652:30)
2018-06-16T05:23:25.449270+00:00 app[web.1]: at
Object.Module._extensions..js (module.js:663:10)
2018-06-16T05:23:25.449271+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T05:23:25.449273+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T05:23:25.449274+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T05:23:25.449276+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T05:23:25.449277+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T05:23:25.457003+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-06-16T05:23:25.457360+00:00 app[web.1]: npm ERR! errno 1
2018-06-16T05:23:25.458445+00:00 app[web.1]: npm ERR! sailcast#1.0.0
start: `node index.js`
2018-06-16T05:23:25.458586+00:00 app[web.1]: npm ERR! Exit status 1
2018-06-16T05:23:25.458827+00:00 app[web.1]: npm ERR!
2018-06-16T05:23:25.458989+00:00 app[web.1]: npm ERR! Failed at the
sailcast#1.0.0 start script.
2018-06-16T05:23:25.459138+00:00 app[web.1]: npm ERR! This is probably
not a problem with npm. There is likely additional logging output above.
2018-06-16T05:23:25.493154+00:00 app[web.1]:
2018-06-16T05:23:25.493346+00:00 app[web.1]: npm ERR! A complete log of
this run can be found in:
2018-06-16T05:23:25.493475+00:00 app[web.1]: npm ERR!
/app/.npm/_logs/2018-06-16T05_23_25_460Z-debug.log
2018-06-16T05:23:25.564550+00:00 heroku[web.1]: Process exited with
status 1
2018-06-16T05:23:25.653739+00:00 heroku[web.1]: State changed from
starting to crashed
2018-06-16T10:54:29.552763+00:00 heroku[web.1]: State changed from
crashed to starting
2018-06-16T10:54:35.778827+00:00 heroku[web.1]: Starting process with
command `npm start`
2018-06-16T10:54:39.194359+00:00 app[web.1]:
2018-06-16T10:54:39.194379+00:00 app[web.1]: > sailcast#1.0.0 start /app
2018-06-16T10:54:39.194381+00:00 app[web.1]: > node index.js
2018-06-16T10:54:39.194383+00:00 app[web.1]:
2018-06-16T10:54:40.337060+00:00 app[web.1]: return
process.dlopen(module, path._makeLong(filename));
2018-06-16T10:54:40.337027+00:00 app[web.1]: module.js:681
2018-06-16T10:54:40.337063+00:00 app[web.1]: ^
2018-06-16T10:54:40.337065+00:00 app[web.1]:
2018-06-16T10:54:40.337067+00:00 app[web.1]: Error:
/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2018-06-16T10:54:40.337069+00:00 app[web.1]: at
Object.Module._extensions..node (module.js:681:18)
2018-06-16T10:54:40.337071+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T10:54:40.337073+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T10:54:40.337074+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T10:54:40.337077+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T10:54:40.337076+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T10:54:40.337079+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/bcrypt/bcrypt.js:6:16)
2018-06-16T10:54:40.337080+00:00 app[web.1]: at Module._compile
(module.js:652:30)
2018-06-16T10:54:40.337082+00:00 app[web.1]: at
Object.Module._extensions..js (module.js:663:10)
2018-06-16T10:54:40.337084+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T10:54:40.337087+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T10:54:40.337085+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T10:54:40.337088+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T10:54:40.337090+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T10:54:40.337091+00:00 app[web.1]: at Object.<anonymous>
(/app/models/user.js:2:16)
2018-06-16T10:54:40.337093+00:00 app[web.1]: at Module._compile
(module.js:652:30)
2018-06-16T10:54:40.337094+00:00 app[web.1]: at
Object.Module._extensions..js (module.js:663:10)
2018-06-16T10:54:40.337096+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-06-16T10:54:40.337097+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-06-16T10:54:40.337099+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-06-16T10:54:40.337100+00:00 app[web.1]: at Module.require
(module.js:596:17)
2018-06-16T10:54:40.337102+00:00 app[web.1]: at require
(internal/module.js:11:18)
2018-06-16T10:54:40.348452+00:00 app[web.1]: npm ERR! code
ELIFECYCLE
2018-06-16T10:54:40.350021+00:00 app[web.1]: npm ERR! errno 1
2018-06-16T10:54:40.355451+00:00 app[web.1]: npm ERR! sailcast#1.0.0
start: `node index.js`
2018-06-16T10:54:40.356150+00:00 app[web.1]: npm ERR! Exit status 1
2018-06-16T10:54:40.357519+00:00 app[web.1]: npm ERR!
2018-06-16T10:54:40.358261+00:00 app[web.1]: npm ERR! Failed at the
sailcast#1.0.0 start script.
2018-06-16T10:54:40.359222+00:00 app[web.1]: npm ERR! This is probably
not a problem with npm. There is likely additional logging output above.
2018-06-16T10:54:40.384205+00:00 app[web.1]:
2018-06-16T10:54:40.384792+00:00 app[web.1]: npm ERR! A complete log of
this run can be found in:
2018-06-16T10:54:40.385145+00:00 app[web.1]: npm ERR!
/app/.npm/_logs/2018-06-16T10_54_40_366Z-debug.log
2018-06-16T10:54:40.480586+00:00 heroku[web.1]: State changed from
starting to crashed
2018-06-16T10:54:40.461008+00:00 heroku[web.1]: Process exited with
status 1
That looks fine. One thing that came up to my mind is that if your file called app.js or index.js since it is an error with npm start? Maybe you made a typo.
Another thing that came up to my mind is that, if you set up the environment database value from the heroku. Since, I cannot see your whole heroku logs, it is another possibility

After stop GULP with CMD+Z got an error: ✗ ... Uhoh. Got error %s ... listen EADDRINUSE

I was working as usual until I stop the server by mistake by playing CMD+Z and got this very big error on my terminal:
[18:02:27] Using gulpfile ~/Documents/Projects/capilleiraclickandgamblemobile/gulpfile.js
[18:02:27] Starting 'sass'...
[18:02:27] Starting 'lint'...
[18:02:29] Finished 'lint' after 1.28 s
[18:02:29] Starting 'run-ionic'...
Running dev server: http://192.168.1.4:8100
✗
✗ ... Uhoh. Got error %s ... listen EADDRINUSE
✗ 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 Server.listen (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/node_modules/tiny-lr-fork/lib/server.js:138:15)
at Object.IonicTask.start (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:164:16)
at /home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:40:10
at Object.IonicTask.getAddress (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:640:11)
at Object.IonicTask.loadSettings (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:71:8)
at Object.IonicTask.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:33:8)
at Object.Ionic.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic.js:537:18)
at Object.<anonymous> (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/bin/ionic:10:7)
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)
at startup (node.js:119:16)
at node.js:929:3
[18:02:30] 'run-ionic' errored after 1.43 s
[18:02:30] Error in plugin 'gulp-shell'
Message:
Command failed: ✗
✗ ... Uhoh. Got error %s ... listen EADDRINUSE
✗ 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 Server.listen (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/node_modules/tiny-lr-fork/lib/server.js:138:15)
at Object.IonicTask.start (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:164:16)
at /home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:40:10
at Object.IonicTask.getAddress (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:640:11)
at Object.IonicTask.loadSettings (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:71:8)
at Object.IonicTask.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:33:8)
at Object.Ionic.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic.js:537:18)
at Object.<anonymous> (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/bin/ionic:10:7)
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)
at startup (node.js:119:16)
at node.js:929:3
Details:
killed: false
code: 1
signal: null
stdout: Running dev server: http://192.168.1.4:8100
stderr: ✗
✗ ... Uhoh. Got error %s ... listen EADDRINUSE
✗ 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 Server.listen (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/node_modules/tiny-lr-fork/lib/server.js:138:15)
at Object.IonicTask.start (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:164:16)
at /home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:40:10
at Object.IonicTask.getAddress (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:640:11)
at Object.IonicTask.loadSettings (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:71:8)
at Object.IonicTask.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic/serve.js:33:8)
at Object.Ionic.run (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/lib/ionic.js:537:18)
at Object.<anonymous> (/home/mretana/.nvm/v0.10.34/lib/node_modules/ionic/bin/ionic:10:7)
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)
at startup (node.js:119:16)
at node.js:929:3
The examples in the docs did not tell me anything, do you have a clue?
I already nvm use 0.10.X and nothing, restart computer and nothing. Also I checked my code and everything is correct.
just restart your console, I just went thru all of this already