簡體   English   中英

我的 node.js 應用程序在本地工作,但在 Heroku 上不起作用,給出了“應用程序錯誤”。 日志尾部是這樣的。 你能幫我解決這個問題嗎?

[英]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?

這是 Heroku 日志尾部:

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

我假設您確實將端口綁定到 Heroku 提供的環境變量$PORT上。 我假設端口是5967 您的程序正在嘗試訪問3306 您可能在某處定義了這個端口。 這在 Heroku 上是不可能的。

Heroku 只允許您綁定到具有 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

你有一個錯誤。 因為您的服務器嘗試連接 3306 端口,但在您的服務器中偵聽端口 5967。簡單地更改自己的代碼 .env 文件中的端口號。 在 .env 文件中定義一個類似的 Eg HOST=5967

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM