Strapi : debug ⛔️ 服务器无法正常启动

Strapi : debug ⛔️ Server wasn't able to start properly

请解决我的问题。

试了50次以上就成功了。现在它不起作用我尝试了100+次。

我启动这个 -> strapi 新服务器

� Starting to create your Strapi application.

? Choose your installation type Custom (manual settings)
? Choose your main database: MongoDB
? Database name: server
? Host: @cluster0-8tfpd.mongodb.net
? +srv connection: true
? Port (It will be ignored if you enable +srv): 27017
? Username: deep
? Password: *******
? Authentication database (Maybe "admin" or blank):
? Enable SSL connection: true

⏳ Testing database connection...
It might take a minute, please have a coffee ☕️

The app has been connected to the database successfully!

�  Application generation:
√ Copy dashboard
√ Install plugin settings-manager.
√ Install plugin content-type-builder.
√ Install plugin content-manager.
√ Install plugin users-permissions.
√ Install plugin email.
√ Install plugin upload.
√ Link strapi dependency to the project.

� Your new application server is ready at E:\Dev. Project\Flutter\flutter_ecommerce\server.

⚡️ Change directory:
$ cd server

⚡️ Start application:
$ strapi start  

但问题是 -> strapi start

[2019-06-15T09:34:30.604Z] debug ⛔️ Server wasn't able to start properly. [2019-06-15T09:34:30.609Z] error Make sure your MongoDB database is running...

请确保您的 MongoDB 是 运行 您在 ./config/environment/.../database.json

中设置的设置

我认为您的主机有 ans 问题,@ 不需要。

我建议您关注有关 Mongo Atlas 文档的 Strapi 文档。 与集群一起工作。 https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#install-on-atlas-mongodb-atlas

  1. 检查是MongoDB实例是运行
  2. 检查 host 的设置是否正确:./config/environment/.../database.json。通常在开发中是localhost

See the picture

您应该在 ./config/environment/.../database.json

中添加条目 uri

uri 应该是 mongodb://<host>:<port>/<database name>

如果您在使用 docker 时遇到此错误, 添加 --network=host 解决了这个问题。请记住,仅在本地使用此解决方案。

正如 docker 本身所述,

--network="host" gives the container full access to local system services such as D-bus and is therefore considered insecure.

如果此错误再次发生,则使用 strapi console 而不是 strapi start