繁体   English   中英

Heroku 无法启动我的 app.js(代码 H10 状态 503)

[英]Heroku Couldn't start my app.js (Code H10 status 503)

让我从截图开始。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

有完整的错误日志

    2020-06-15T10:46:45.640400+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-15T10:46:47.833544+00:00 app[web.1]: 
2020-06-15T10:46:47.833563+00:00 app[web.1]: > learn-blog@1.0.0 start /app
2020-06-15T10:46:47.833563+00:00 app[web.1]: > node app.js
2020-06-15T10:46:47.833563+00:00 app[web.1]: 
2020-06-15T10:47:22.069169+00:00 app[web.1]: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
2020-06-15T10:47:22.069203+00:00 app[web.1]:     at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:826:32)
2020-06-15T10:47:22.069204+00:00 app[web.1]:     at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:335:15)
2020-06-15T10:47:22.069204+00:00 app[web.1]:     at run (/app/app_server/server/server.js:26:20)
2020-06-15T10:47:22.069204+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:3:1)
2020-06-15T10:47:22.069205+00:00 app[web.1]:     at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-06-15T10:47:22.069205+00:00 app[web.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-06-15T10:47:22.069205+00:00 app[web.1]:     at Module.load (internal/modules/cjs/loader.js:986:32)
2020-06-15T10:47:22.069205+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-06-15T10:47:22.069206+00:00 app[web.1]:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
2020-06-15T10:47:22.069206+00:00 app[web.1]:     at internal/main/run_main_module.js:17:47 {
2020-06-15T10:47:22.069207+00:00 app[web.1]:   reason: TopologyDescription {
2020-06-15T10:47:22.069207+00:00 app[web.1]:     type: 'ReplicaSetNoPrimary',
2020-06-15T10:47:22.069207+00:00 app[web.1]:     setName: null,
2020-06-15T10:47:22.069207+00:00 app[web.1]:     maxSetVersion: null,
2020-06-15T10:47:22.069207+00:00 app[web.1]:     maxElectionId: null,
2020-06-15T10:47:22.069208+00:00 app[web.1]:     servers: Map {
2020-06-15T10:47:22.069208+00:00 app[web.1]:       'learningcluster-shard-00-01-izdfm.mongodb.net:27017' => [ServerDescription],
2020-06-15T10:47:22.069208+00:00 app[web.1]:       'learningcluster-shard-00-02-izdfm.mongodb.net:27017' => [ServerDescription],
2020-06-15T10:47:22.069208+00:00 app[web.1]:       'learningcluster-shard-00-00-izdfm.mongodb.net:27017' => [ServerDescription]
2020-06-15T10:47:22.069209+00:00 app[web.1]:     },
2020-06-15T10:47:22.069209+00:00 app[web.1]:     stale: false,
2020-06-15T10:47:22.069209+00:00 app[web.1]:     compatible: true,
2020-06-15T10:47:22.069210+00:00 app[web.1]:     compatibilityError: null,
2020-06-15T10:47:22.069210+00:00 app[web.1]:     logicalSessionTimeoutMinutes: null,
2020-06-15T10:47:22.069210+00:00 app[web.1]:     heartbeatFrequencyMS: 10000,
2020-06-15T10:47:22.069210+00:00 app[web.1]:     localThresholdMS: 15,
2020-06-15T10:47:22.069210+00:00 app[web.1]:     commonWireVersion: null
2020-06-15T10:47:22.069211+00:00 app[web.1]:   }
2020-06-15T10:47:22.069211+00:00 app[web.1]: }
2020-06-15T10:47:22.143281+00:00 heroku[web.1]: Process exited with status 0
2020-06-15T10:47:22.184007+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-15T10:48:10.737182+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-taiga-29926.herokuapp.com request_id=840ea8ca-9d88-451d-9720-77cbafc687c0 fwd="88.238.178.195" dyno= connect= service= status=503 bytes= protocol=https
2020-06-15T10:48:11.205261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=morning-taiga-29926.herokuapp.com request_id=2f1efa47-f83b-4d52-8d1c-2a7e45e7b666 fwd="88.238.178.195" dyno= connect= service= status=503 bytes= protocol=https

我检查了我的 mongodb atlas 集群,我的 ip 地址在白名单中。 另外,我尝试将网络访问设置为0.0.0.0/0但它也没有工作......

顺便说一句,一切都在我的本地地址(8080)中完美运行。

我修好了它。

在此处输入图像描述

我在我的代码中添加了这些东西;

mongoose.Promise = global.Promise;

...

const PORT = process.env.PORT || 8080;    
const CONNECTION_URI = process.env.MONGODB_URI || 'mongodb+srv://learnBlogAdmin:learnBlogAdminsPowsyetmiş22a@learningcluster-izdfm.mongodb.net/personalblog?retryWrites=true&w=majority';

...

run()
    .then(() => {
        console.log("IT WORKS");
    })
    .catch((err) => {
        console.log(err);
        throw err;
    })

它奏效了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM