Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在Heroku MongoDB连接上部署应用程序时出错_Node.js_Mongodb_Express_Heroku_Mongodb Atlas - Fatal编程技术网

Node.js 在Heroku MongoDB连接上部署应用程序时出错

Node.js 在Heroku MongoDB连接上部署应用程序时出错,node.js,mongodb,express,heroku,mongodb-atlas,Node.js,Mongodb,Express,Heroku,Mongodb Atlas,我使用express和MongoDB创建了这个应用程序。当我在本地运行应用程序时,它运行得非常好。我在MongoDB atlas上创建了一个PostDB数据库,并生成并获取了连接字符串。我想使用heroku部署此应用程序,但我不知道为什么会出现此错误。请帮助我。提前谢谢 这是我的连接字符串: mongoose.connect("\mongodb+srv://Admin:minnu@mongodb01.irdlb.mongodb.net/PostDB",{useNewUrlPa

我使用express和MongoDB创建了这个应用程序。当我在本地运行应用程序时,它运行得非常好。我在MongoDB atlas上创建了一个PostDB数据库,并生成并获取了连接字符串。我想使用heroku部署此应用程序,但我不知道为什么会出现此错误。请帮助我。提前谢谢

这是我的连接字符串:

mongoose.connect("\mongodb+srv://Admin:minnu@mongodb01.irdlb.mongodb.net/PostDB",{useNewUrlParser:true,useCreateIndex:true, useUnifiedTopology: true},function(err,db){
  if (err) {
      console.log('Unable to connect to the server. Please start the server. Error:', err);
  } else {
      console.log('Connected to Server successfully!');
  }});                                                                     
这是我得到的错误:

2020-07-22T13:10:59.614060+00:00 app[web.1]: commonWireVersion: null
2020-07-22T13:10:59.614061+00:00 app[web.1]: }
2020-07-22T13:10:59.614061+00:00 app[web.1]: }
2020-07-22T13:10:59.631071+00:00 app[web.1]: Unable to connect to the server. Please start the server. Error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
2020-07-22T13:10:59.631074+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:828:32)
2020-07-22T13:10:59.631075+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:335:15)
2020-07-22T13:10:59.631076+00:00 app[web.1]: at Object.<anonymous> (/app/Models/User.js:2:10)
2020-07-22T13:10:59.631076+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631077+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631077+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631078+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631078+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at Object.<anonymous> (/app/Routes/Posts.js:6:12)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631080+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631080+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18) {
2020-07-22T13:10:59.631082+00:00 app[web.1]: reason: TopologyDescription {
2020-07-22T13:10:59.631082+00:00 app[web.1]: type: 'Single',
2020-07-22T13:10:59.631083+00:00 app[web.1]: setName: null,
2020-07-22T13:10:59.631083+00:00 app[web.1]: maxSetVersion: null,
2020-07-22T13:10:59.631083+00:00 app[web.1]: maxElectionId: null,
2020-07-22T13:10:59.631084+00:00 app[web.1]: servers: Map { 'localhost:27017' => [ServerDescription] },
2020-07-22T13:10:59.631084+00:00 app[web.1]: stale: false,
2020-07-22T13:10:59.631085+00:00 app[web.1]: compatible: true,
2020-07-22T13:10:59.631085+00:00 app[web.1]: compatibilityError: null,
2020-07-22T13:10:59.631086+00:00 app[web.1]: logicalSessionTimeoutMinutes: null,
2020-07-22T13:10:59.631086+00:00 app[web.1]: heartbeatFrequencyMS: 10000,
2020-07-22T13:10:59.631086+00:00 app[web.1]: localThresholdMS: 15,
2020-07-22T13:10:59.631087+00:00 app[web.1]: commonWireVersion: null
2020-07-22T13:10:59.631087+00:00 app[web.1]: }
2020-07-22T13:10:59.631087+00:00 app[web.1]: }
2020-07-22T13:11:29.817201+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T13:43:44.978055+00:00 heroku[web.1]: Idling
2020-07-22T13:43:44.980176+00:00 heroku[web.1]: State changed from up to down
2020-07-22T13:43:46.293776+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T13:43:46.385591+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:23:20.000000+00:00 app[api]: Build started by user mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.274124+00:00 app[api]: Deploy 9e2202b9 by user mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.274124+00:00 app[api]: Release v9 created by user mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.454375+00:00 heroku[web.1]: State changed from down to starting
2020-07-22T15:23:42.000000+00:00 app[api]: Build succeeded
2020-07-22T15:23:43.755247+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:23:46.020199+00:00 app[web.1]:
2020-07-22T15:23:46.020218+00:00 app[web.1]: > ejs-challenge@1.0.0 start /app
2020-07-22T15:23:46.020219+00:00 app[web.1]: > node app.js
2020-07-22T15:23:46.020219+00:00 app[web.1]:
2020-07-22T15:23:46.753513+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:23:46.753525+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:23:46.753554+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:23:46.770376+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:23:47.305407+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T15:23:48.056394+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:23:48.059001+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:24:25.538134+00:00 heroku[router]: at=info method=GET path="/" host=shielded-citadel-75286.herokuapp.com request_id=a2276768-c8b4-4937-a8f9-feb2e1cc9d00 fwd="106.200.146.62" dyno=web.1 connect=0ms service=1360ms status=200 bytes=4199 protocol=https
2020-07-22T15:24:26.201469+00:00 heroku[router]: at=info method=GET path="/css/styles.css" host=shielded-citadel-75286.herokuapp.com request_id=1d330f4c-66fd-407c-a8ed-57ba80507318 fwd="106.200.146.62" dyno=web.1 connect=1ms service=9ms status=200 bytes=2179 protocol=https
2020-07-22T15:24:26.284481+00:00 heroku[router]: at=info method=GET path="/images/logo.jpg" host=shielded-citadel-75286.herokuapp.com request_id=96a94f69-2984-4b7f-8e5e-1ae6f12493e6 fwd="106.200.146.62" dyno=web.1 connect=0ms service=11ms status=200 bytes=8897 protocol=https
2020-07-22T15:24:26.318935+00:00 heroku[router]: at=info method=GET path="/images/butterfly.gif" host=shielded-citadel-75286.herokuapp.com request_id=f54f11ef-31a4-4fdf-ad7f-c5d47c354afb fwd="106.200.146.62" dyno=web.1 connect=0ms service=45ms status=200 bytes=687572 protocol=https
2020-07-22T15:24:51.370552+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=shielded-citadel-75286.herokuapp.com request_id=396f3ab9-b44b-4432-888e-792eb45268e2 fwd="106.200.146.62" dyno=web.1 connect=0ms service=5ms status=404 bytes=394 protocol=https
2020-07-22T15:26:13.000000+00:00 app[api]: Build started by user mamadgiaishwarya@gmail.com
2020-07-22T15:26:35.089490+00:00 app[api]: Release v10 created by user mamadgiaishwarya@gmail.com
2020-07-22T15:26:35.089490+00:00 app[api]: Deploy 7fd231d2 by user mamadgiaishwarya@gmail.com
2020-07-22T15:26:36.000000+00:00 app[api]: Build succeeded
2020-07-22T15:26:36.726907+00:00 heroku[web.1]: Restarting
2020-07-22T15:26:36.741521+00:00 heroku[web.1]: State changed from up to starting
2020-07-22T15:26:37.654962+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T15:26:37.782161+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:26:39.941929+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:26:42.451886+00:00 app[web.1]:
2020-07-22T15:26:42.451908+00:00 app[web.1]: > ejs-challenge@1.0.0 start /app
2020-07-22T15:26:42.451908+00:00 app[web.1]: > node app.js
2020-07-22T15:26:42.451909+00:00 app[web.1]:
2020-07-22T15:26:43.528332+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:26:43.528343+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:26:43.528344+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:26:43.537025+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:26:43.977021+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T15:26:44.829130+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:26:44.831445+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:28:23.000000+00:00 app[api]: Build started by user mamadgiaishwarya@gmail.com
2020-07-22T15:28:45.263212+00:00 app[api]: Deploy c7cbd9d0 by user mamadgiaishwarya@gmail.com
2020-07-22T15:28:45.263212+00:00 app[api]: Release v11 created by user mamadgiaishwarya@gmail.com
2020-07-22T15:28:45.446526+00:00 heroku[web.1]: Restarting
2020-07-22T15:28:45.448387+00:00 heroku[web.1]: State changed from up to starting
2020-07-22T15:28:46.000000+00:00 app[api]: Build succeeded
2020-07-22T15:28:46.651703+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T15:28:46.746865+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:28:49.098450+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:28:51.924571+00:00 app[web.1]:
2020-07-22T15:28:51.924589+00:00 app[web.1]: > ejs-challenge@1.0.0 start /app
2020-07-22T15:28:51.924589+00:00 app[web.1]: > node app.js
2020-07-22T15:28:51.924589+00:00 app[web.1]:
2020-07-22T15:28:52.898117+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:28:52.898161+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:28:52.898162+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:28:52.905188+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:28:53.428020+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T13:10:59.614060+00:00应用程序[web.1]:commonWireVersion:null
2020-07-22T13:10:59.614061+00:00应用程序[web.1]:}
2020-07-22T13:10:59.614061+00:00应用程序[web.1]:}
2020-07-22T13:10:59.631071+00:00应用程序[web.1]:无法连接到服务器。请启动服务器。错误:MongooseServerSelectionError:connect-EconReflected 127.0.0.1:27017
2020-07-22T13:10:59.631074+00:00应用程序[web.1]:位于NativeConnection.Connection.openUri(/app/node\u modules/mongoose/lib/Connection.js:828:32)
2020-07-22T13:10:59.631075+00:00应用程序[web.1]:位于Mongoose.connect(/app/node_modules/Mongoose/lib/index.js:335:15)
2020-07-22T13:10:59.631076+00:00应用程序[web.1]:at对象。(/app/Models/User.js:2:10)
2020-07-22T13:10:59.631076+00:00应用程序[web.1]:at模块编译(internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631077+00:00应用程序[web.1]:at Object.Module.\u extensions..js(internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631077+00:00应用程序[web.1]:at Module.load(内部/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631078+00:00应用程序[web.1]:at Function.Module._load(内部/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631078+00:00应用程序[web.1]:at Module.require(内部/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631079+00:00应用程序[web.1]:根据需要(内部/modules/cjs/helpers.js:72:18)
2020-07-22T13:10:59.631079+00:00应用程序[web.1]:at对象。(/app/Routes/Posts.js:6:12)
2020-07-22T13:10:59.631079+00:00应用程序[web.1]:at模块编译(internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631080+00:00应用程序[web.1]:at Object.modules._extensions..js(internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631080+00:00应用程序[web.1]:at Module.load(内部/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631081+00:00应用程序[web.1]:at Function.Module._load(内部/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631081+00:00应用程序[web.1]:at Module.require(内部/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631081+00:00应用程序[web.1]:根据需要(内部/modules/cjs/helpers.js:72:18){
2020-07-22T13:10:59.631082+00:00应用程序[web.1]:原因:地形描述{
2020-07-22T13:10:59.631082+00:00应用程序[web.1]:键入:“Single”,
2020-07-22T13:10:59.631083+00:00应用程序[web.1]:setName:null,
2020-07-22T13:10:59.631083+00:00应用程序[web.1]:maxSetVersion:null,
2020-07-22T13:10:59.631083+00:00应用程序[web.1]:maxElectionId:null,
2020-07-22T13:10:59.631084+00:00应用程序[web.1]:服务器:映射{'localhost:27017'=>[ServerDescription]},
2020-07-22T13:10:59.631084+00:00应用程序[web.1]:过时:错误,
2020-07-22T13:10:59.631085+00:00应用程序[web.1]:兼容:正确,
2020-07-22T13:10:59.631085+00:00应用程序[web.1]:兼容性错误:null,
2020-07-22T13:10:59.631086+00:00应用程序[web.1]:logicalSessionTimeoutMinutes:null,
2020-07-22T13:10:59.631086+00:00应用程序[web.1]:心跳频率:10000,
2020-07-22T13:10:59.631086+00:00应用程序[web.1]:localThresholdMS:15,
2020-07-22T13:10:59.631087+00:00应用程序[web.1]:commonWireVersion:null
2020-07-22T13:10:59.631087+00:00应用程序[web.1]:}
2020-07-22T13:10:59.631087+00:00应用程序[web.1]:}
2020-07-22T13:11:29.817201+00:00 heroku[web.1]:状态从启动更改为启动
2020-07-22T13:43:44.978055+00:00 heroku[web.1]:空转
2020-07-22T13:43:44.980176+00:00 heroku[web.1]:状态由上变下
2020-07-22T13:43:46.293776+00:00 heroku[web.1]:使用SIGTERM停止所有进程
2020-07-22T13:43:46.385591+00:00 heroku[web.1]:进程退出,状态为143
2020-07-22T15:23:20.000000+00:00应用程序[api]:由用户启动构建mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.274124+00:00应用程序[api]:按用户部署9e2202b9mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.274124+00:00应用程序[api]:由用户创建的v9版本mamadgiaishwarya@gmail.com
2020-07-22T15:23:41.454375+00:00 heroku[web.1]:状态从“向下”更改为“开始”
2020-07-22T15:23:42.000000+00:00应用程序[api]:构建成功
2020-07-22T15:23:43.755247+00:00 heroku[web.1]:使用命令“npm start”启动进程`
2020-07-22T15:23:46.0201999+00:00应用程序[网站1]:
2020-07-22T15:23:46.02018+00:00应用程序[web.1]:>ejs-challenge@1.0.0启动/应用程序
2020-07-22T15:23:46.02019+00:00应用程序[web.1]:>node app.js
2020-07-22T15:23:46.02019+00:00应用程序[网站1]:
2020-07-22T15:23:46.753513+00:00应用程序[web.1]:警告:connect.session()内存存储不可用
2020-07-22T15:23:46.753525+00:00应用程序[web.1]:专为生产环境设计,因为它会泄漏
2020-07-22T15:23:46.753554+00:00应用程序[web.1]:内存,并且不会超过单个进程。
2020-07-22T15:23:46.770376+00:00应用程序[web.1]:服务器已在端口3000上启动
2020-07-22T15:23:47.305407+00:00 heroku[web.1]:状态从启动更改为启动
2020-07-22T15:23:48.056394+00:00应用程序[web.1]:已成功连接到服务器!
2020-07-22T15:23:48.059001+00:00应用程序[web.1]:已成功连接到服务器!
2020-07-22T15:24:25.538134+00:00 heroku[路由器]:at=info method=GET path=“/”host=shield-citadel-75286.herokuapp.com请求\u id=a2276768-c8b4-4937-a8f9-feb2e1cc9d00 fwd=“106.200.146.62”dyno=web.1 connect=0ms服务=1360ms状态=200字节=4199协议=https
2020-07-22T15:24:26.201469+00:00 heroku[路由器]:at=info method=GET path=“/css/styles.css”host=shield-citadel-75286.herokuapp.com request_id=1d330f4c-66fd-407c-a8ed-57ba80507318 fwd=“106.200.146.62”dyno=web.1 connect=1ms service=9ms status=200字节=2179协议=https
2020-07-22T15:24:26.284481+00:00 heroku[路由器]:at=info method=GET path=“/images/logo.jpg”host=shield-citadel-75286.herokuapp.com request_id=96a94f69-2984-4b7f-8e5e-1AE6f16lang1024 fwd=“106.200.146.62”dyno=web.1 connect=0ms服务=11ms状态=200字节=8897协议=https
2020-0