Node.js 如何更改heroku服务器运行的端口?

Node.js 如何更改heroku服务器运行的端口?,node.js,heroku,ssl-certificate,heroku-cli,Node.js,Heroku,Ssl Certificate,Heroku Cli,我刚刚将服务器配置为支持带有SSL证书的https,我在heroku日志中发现了这个奇怪的错误 错误:侦听EADDRINUSE:地址已在使用中:::23736 2019-07-02T20:29:56.810153+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::23736 2019-07-02T20:29:56.810155+00:00 app[web.1]: at Server.setupLis

我刚刚将服务器配置为支持带有SSL证书的https,我在heroku日志中发现了这个奇怪的错误

错误:侦听EADDRINUSE:地址已在使用中:::23736

2019-07-02T20:29:56.810153+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::23736
2019-07-02T20:29:56.810155+00:00 app[web.1]:     at Server.setupListenHandle [as _listen2] (net.js:1279:14)
2019-07-02T20:29:56.810157+00:00 app[web.1]:     at listenInCluster (net.js:1327:12)
2019-07-02T20:29:56.810160+00:00 app[web.1]:     at Server.listen (net.js:1414:7)
2019-07-02T20:29:56.810162+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:103:12)
2019-07-02T20:29:56.810163+00:00 app[web.1]:     at Module._compile (internal/modules/cjs/loader.js:776:30)
2019-07-02T20:29:56.810166+00:00 app[web.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2019-07-02T20:29:56.810168+00:00 app[web.1]:     at Module.load (internal/modules/cjs/loader.js:653:32)
2019-07-02T20:29:56.810170+00:00 app[web.1]:     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-07-02T20:29:56.810171+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-07-02T20:29:56.810174+00:00 app[web.1]:     at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
2019-07-02T20:29:56.810176+00:00 app[web.1]: Emitted 'error' event at:
2019-07-02T20:29:56.810178+00:00 app[web.1]:     at emitErrorNT (net.js:1306:8)
2019-07-02T20:29:56.810180+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:63:19)
2019-07-02T20:29:56.810182+00:00 app[web.1]:     at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
2019-07-02T20:29:56.810184+00:00 app[web.1]:     at startup (internal/bootstrap/node.js:283:19)
2019-07-02T20:29:56.810186+00:00 app[web.1]:     at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
2019-07-02T20:29:56.819819+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-07-02T20:29:56.820414+00:00 app[web.1]: npm ERR! errno 1
2019-07-02T20:29:56.822143+00:00 app[web.1]: npm ERR! gbahdeyboh@1.0.0 start: `node server.js`
2019-07-02T20:29:56.822348+00:00 app[web.1]: npm ERR! Exit status 1
2019-07-02T20:29:56.822671+00:00 app[web.1]: npm ERR! 
2019-07-02T20:29:56.822893+00:00 app[web.1]: npm ERR! Failed at the gbahdeyboh@1.0.0 start script.
2019-07-02T20:29:56.823098+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-07-02T20:29:56.829332+00:00 app[web.1]: 
2019-07-02T20:29:56.829583+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-07-02T20:29:56.829738+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-07-02T20_29_56_825Z-debug.log
2019-07-02T20:29:56.895827+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-02T20:29:56.902570+00:00 heroku[web.1]: State changed from crashed to starting
2019-07-02T20:29:56.878861+00:00 heroku[web.1]: Process exited with status 1
2019-07-02T20:29:56.810153+00:00应用程序[web.1]:错误:侦听EADDRINUSE:地址已在使用中:::23736
2019-07-02T20:29:56.810155+00:00应用程序[web.1]:在Server.setupListenHandle[as_listen2](net.js:1279:14)
2019-07-02T20:29:56.810157+00:00应用程序[网站1]:在Listenicluster(net.js:1327:12)
2019-07-02T20:29:56.810160+00:00应用程序[web.1]:在Server.listen(net.js:1414:7)
2019-07-02T20:29:56.810162+00:00应用程序[web.1]:at对象。(/app/server.js:103:12)
2019-07-02T20:29:56.810163+00:00应用程序[web.1]:at模块编译(internal/modules/cjs/loader.js:776:30)
2019-07-02T20:29:56.810166+00:00应用程序[web.1]:at Object.modules._extensions..js(internal/modules/cjs/loader.js:787:10)
2019-07-02T20:29:56.810168+00:00应用程序[web.1]:at Module.load(内部/modules/cjs/loader.js:653:32)
2019-07-02T20:29:56.810170+00:00应用程序[网站1]:在tryModuleLoad(内部/modules/cjs/loader.js:593:12)
2019-07-02T20:29:56.810171+00:00应用程序[web.1]:at功能模块加载(内部/modules/cjs/loader.js:585:3)
2019-07-02T20:29:56.810174+00:00应用程序[web.1]:位于Function.Module.runMain(internal/modules/cjs/loader.js:829:12)
2019-07-02T20:29:56.810176+00:00应用程序[web.1]:在以下位置发出“错误”事件:
2019-07-02T20:29:56.810178+00:00应用程序[web.1]:在emitErrorNT(net.js:1306:8)
2019-07-02T20:29:56.810180+00:00应用程序[web.1]:在进程中进行回调(内部/进程/下一个进程js:63:19)
2019-07-02T20:29:56.810182+00:00应用程序[web.1]:位于Function.Module.runMain(internal/modules/cjs/loader.js:832:11)
2019-07-02T20:29:56.810184+00:00应用程序[web.1]:启动时(内部/bootstrap/node.js:283:19)
2019-07-02T20:29:56.810186+00:00应用程序[web.1]:位于bootstrapNodeJSCore(internal/bootstrap/node.js:622:3)
2019-07-02T20:29:56.819819+00:00应用程序[网站1]:npm错误!代码失效循环
2019-07-02T20:29:56.820414+00:00应用程序[网站1]:npm错误!错误1
2019-07-02T20:29:56.822143+00:00应用程序[网站1]:npm错误!gbahdeyboh@1.0.0start:`node server.js`
2019-07-02T20:29:56.822348+00:00应用程序[网站1]:npm错误!退出状态1
2019-07-02T20:29:56.822671+00:00应用程序[网站1]:npm错误!
2019-07-02T20:29:56.822893+00:00应用程序[网站1]:npm错误!失败gbahdeyboh@1.0.0开始脚本。
2019-07-02T20:29:56.823098+00:00应用程序[网站1]:npm错误!这可能不是npm的问题。上面可能还有其他日志输出。
2019-07-02T20:29:56.829332+00:00应用程序[网站1]:
2019-07-02T20:29:56.829583+00:00应用程序[网站1]:npm错误!此运行的完整日志可在以下位置找到:
2019-07-02T20:29:56.829738+00:00应用程序[网站1]:npm错误/app/.npm/_logs/2019-07-02T20_29_56_825Z-debug.log
2019-07-02T20:29:56.895827+00:00 heroku[web.1]:状态从开始更改为崩溃
2019-07-02T20:29:56.902570+00:00 heroku[web.1]:状态从崩溃变为启动
2019-07-02T20:29:56.878861+00:00 heroku[web.1]:进程退出,状态为1

是否有办法更改heroku服务器侦听的端口?

此错误可能发生在您进行配置之后?如果是这种情况,那么请告诉我们有关这些配置的更多详细信息,以便我们可以更好地帮助您“我刚刚配置了我的服务器以支持带有SSL证书的https”-如何?通常这不会导致您描述的错误。事实证明,在添加https侦听器之前,我忘记注释侦听http请求的代码行。由于http和https都在生产环境变量上指定的端口上侦听,因此在触发第二个侦听器之前,这两个端口中的一个将使用该端口,这就是我收到“地址已在使用”错误的原因。此错误可能是在您进行配置之后发生的?如果是这种情况,那么请告诉我们有关这些配置的更多详细信息,以便我们可以更好地帮助您“我刚刚配置了我的服务器以支持带有SSL证书的https”-如何?通常这不会导致您描述的错误。事实证明,在添加https侦听器之前,我忘记注释侦听http请求的代码行。由于http和https都在生产环境变量上指定的端口上侦听,因此在触发第二个侦听器之前,该端口将被其中一个使用,这就是我收到“地址已在使用”错误的原因