簡體   English   中英

Rails db:create using PostgreSQL return 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM