0

i am unable to connect My rails app with PostgreSQL database which is running on my Ubuntu server running on certain instance.I created new user and password by using the following command.

1-sudo -u postgres createuser -s user1
2-sudo -u postgres psql.
3-postgres=\\password userpass

Check my database.yml file which is given below.

database.yml:

development:
  adapter: postgresql
  encoding: unicode
  database: 100sallon_development
  pool: 5
  username: user1
  password: *******
  host: 10.*.*.*
test:
  adapter: postgresql
  encoding: unicode
  database: 100sallon_test
  pool: 5
  username: user1
  password:  *******
  host: 10.*.*.*

production:
  adapter: postgresql
  encoding: unicode
  database: 100sallon_production
  pool: 5
  username: user1
  password: ******
  host: 10.*.*.*

When i tried to create the database using the below command rake db:create it gave me the below error.

Error:

could not connect to server:connection refused
      Is the server running on the host:10.*.*.* and accepting
      TCP/IP connections on the port 5432

My Ubuntu server is running on given IP.But still face problem to connect with the PostgreSQL database.Please help me to resolve this error.Thank you.

satya
  • 3,508
  • 11
  • 50
  • 130
  • try without the host – Gautam Sep 10 '15 at 04:06
  • @nik : according to you i removed the host but it is giving the error ` Fatal : Peer authentication failed for user user1. – satya Sep 10 '15 at 04:09
  • Follow the accepted answer in this [question](http://stackoverflow.com/questions/9987171/rails-3-2-fatal-peer-authentication-failed-for-user-pgerror) and your problem will be resolved – Gautam Sep 10 '15 at 04:28
  • 1
    check you firewall settings. If port 5432 is open - also validate your `pg_hba.conf` so it contains your app/client IP entries with `md5` or `trust` (not recommended).if you change pg_hba.conf - make sure to reload configuration in postgres. – Dmitry S Sep 10 '15 at 04:29
  • what is your `listen_addresses` in postgresql.conf ? – alexius Sep 10 '15 at 04:34
  • @ alexius : Actually i am new to PostgreSQL.Can you please tell me how i will check this. – satya Sep 10 '15 at 04:36
  • @ alexius : i checked using command `sudo netstat -tulpn` and found there this confugration `1117/TCP 0 0.0.0.0:25 0.0.0.0 LISTEN`. – satya Sep 10 '15 at 04:53

0 Answers0