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.

7
  • try without the host Commented Sep 10, 2015 at 4:06
  • @nik : according to you i removed the host but it is giving the error ` Fatal : Peer authentication failed for user user1. Commented Sep 10, 2015 at 4:09
  • Follow the accepted answer in this question and your problem will be resolved Commented Sep 10, 2015 at 4: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. Commented Sep 10, 2015 at 4:29
  • what is your listen_addresses in postgresql.conf ? Commented Sep 10, 2015 at 4:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.