简体   繁体   中英

RoR project - can't connect to remote postgres DB server

Yeah, I know it was asked a lot of times, and still I can't find right answer. So settings is:

1)I'm running server on Ubuntu 14, console info:

...
* Environment: development
* Listening on tcp://localhost:3000

So env is development

2) database.yml :

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: dbmane
  username: developer_dbmane
  PASSWORD: some_pass
  HOST: xxx.xxx.xxx.128
  port: 5432

3) http://localhost:3000/ reports:

"could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?"

...

@config

{:adapter=>"postgresql", :encoding=>"unicode", :pool=>5, :database=>"dbname", :username=>"developer_dbname", :PASSWORD=>"some_pass", :HOST=>"xxx.xxx.xxx.128", :port=>5432}

@connection_parameters

{:port=>5432, :user=>"developer_i18n", :dbname=>"i18n"}

4) I CAN connect remote DB with command:

psql -hxxx.xxx.xxx.128 -Udeveloper_dbname dbname

Authorization is fine too - so remote server DO acccept remote connections

5) Local postgress server is shuted down, but if it not: Ruby server trying to connect to it.

So the question is how to configure it to connect remote, not local server after all?

Yaml is case-sensitive, so the problem is probably that it doesn't recoginze the host and password settings.

Try to use this:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: dbmane
  username: developer_dbmane
  password: some_pass
  host: xxx.xxx.xxx.128
  port: 5432

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM