Strapi因端口被占用而无法启动的解决方法

后端开发Strapi 923

Strapi在启动时出现错误

strapi start
[2019-10-11T07:13:43.293Z] debug ⛔️ Server wasn't able to start properly.
[2019-10-11T07:13:43.294Z] error The port 1337 is already used by another application.

这是因为端口被其它应用占用了,我们只需要查看占用1337端口的程序相应退出或者更换strapi服务端口就可以解决这个问题。

端口的配置方法

配置端口需要注意两个文件:

  • 生产环境:./config/environments/production/server.json
  • 开发环境:./config/environments/development/server.json

在这两个文件中分别修改对应的端口号即可

"port": "${process.env.PORT || 1337}",

"port": 1337,

修改后重新使用strapi start命令即可成功启动服务。

Post Comment