Can not connect Rails app with PostgreSQL on ubunt

2019-09-08 05:32发布

问题:

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.