有很多類似的問題,但都略有不同。rails 4 PG :: ConnectionBad無法連接到服務器
的Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'rspec-rails', '~> 3.4'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
的Rails 4.2.6,並在命令行做psql
返回:
PG::ConnectionBad (could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
也得到了在瀏覽器中相同的原料鐵軌服務器和嘗試後加載根路徑。
我發現,在命令行做postgres
沒有任何工作,返回:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
你的Postgres服務器必須運行。它不負責Rails啓動數據庫服務器 – DennisCastro