サンプルの Rails アプリをリモート サーバーにデプロイし、同じサーバーで postgres をホストしました。database.yml ファイルはこんな感じでした。
production:
adapter: postgresql
encoding: unicode
database: remotepg_production
pool: 5
host: localhost
username: mrmann
password: secret
すべてがうまくいきました。次に、database.yml ファイルに移動し、このようなhost: localhost
別のサーバー上の postgres データベースの IP アドレスに置き換えましたhost: 178.XXX.XXX
production:
adapter: postgresql
encoding: unicode
database: remotepg_production
pool: 5
host: 178.XXX.XXX.XXX #ip address of server with other postgres database
username: mrmann
password: secret
サーバーで Rails アプリを使用して postgres を再起動すると、サンプル アプリケーションで Rails の「問題が発生しました」というページが表示されるようになりました。
ユーザー名とユーザー名のパスワードは、両方のデータベースで同じです。問題が何であるかを提案できますか?ありがとう
アップデート
これらは、接続したいデータベースがあるサーバーの pg_hba.conf の設定です。
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
偽の Rails アプリの IP: 192.241.XXX.X
偽のデータベース IP: 192.34.XX.XXX