![](/img/trans.png)
[英]Rails - Postgres - could not connect to server: Connection refused (PG::ConnectionBad)
[英]Rails db:create using PostgreSQL return PG::ConnectionBad: could not connect to server: Connection refused
我正在按照教程使用DigitalOcean 教程中的react 和 rails 进行开发。
我已经做好了
rails new rails_react_recipe -d=postgresql -T --webpack=react --skip-coffee
它创建了包含所有必要工具的目录 - ruby 和 rails。 然后下一步就是创建数据库
rails db:create
但它返回了我下面的错误
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Couldn't create 'rails_react_recipe_development' database. Please check your configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
我已经从https://www.postgresql.org/download/为 windows 安装了 postgresql 12
我在网上找不到任何解决方案。 帮助将不胜感激。 谢谢!
您需要启动 Postgres 服务器才能开始接受连接。 目前,您可能已经下载了 Postgres,但尚未启动它。
您可以按照此处的说明了解如何在 Windows 上启动它: https : //tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.