[英]PG::ConnectionBad - could not connect to server: Connection refused
[英]PG::ConnectionBad - could not connect to server: Connection refused on Mac OS X
使用以下rvm install 2.7.1
所需的ruby
版本: rvm install 2.7.1
並安裝所有 gems 后,我計划使用rails db:create
數據庫,但出現此錯誤:
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5442?
Couldn't create 'development' database. Please check the configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5442?
我的database.yml
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 15 } %>
host: <%= ENV.fetch("DATABASE_HOST") { '127.0.0.1' } %>
development:
<<: *default
database: development
test:
<<: *default
database: test
production:
<<: *default
database: production
似乎它與postgres有關。 它的版本是: postgres (postgreSQL) 12.4
pg
gem 版本是1.2.3
重新啟動postgresql
沒有幫助
看來我需要創建一個新的 PostgreSQL 數據庫集群。 首先,您需要刪除/usr/local/var/
中的postgres
目錄
您可以使用此代碼 - cd /usr/local/var/ && rm -rf postgres
之后 - 創建新的postgres
文件夾mkdir postgres
(在/usr/local/var
)
並使用 - 初始化新 PostgreSQL 數據庫集群的創建
cd && initdb --locale=C -E UTF-8 /usr/local/var/postgres
最后一件事,重啟postgres—— brew services restart postgresql
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.