1

in database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: demo_test_development
  pool: 5
  username: adarsh
  password: 
  timeout: 5000
  host: localhost
  port: 5432

test:
  adapter: postgresql
  encoding: unicode
  database: demo_test_test
  pool: 5
  username: adarsh
  password: 
  timeout: 5000
  host: localhost
  port: 5432

in gem file

group :development do

    gem 'pg'
    gem 'taps'

end

then I do

1) Bundle install (is working)

2)rake db:setup,db:create,db:migrate(but is not working)

Getting error : could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? Couldn't create 'demo_test_development' database. Please check your configuration.

15
  • 1
    Please check if postgres service has started or not and have you installed postgresql in your system???and created a user named adarsh Commented Jan 3, 2019 at 6:34
  • 1
    Refer to this link digitalocean.com/community/tutorials/… Commented Jan 3, 2019 at 6:42
  • 1
    after installing create a user and restart postgres service Commented Jan 3, 2019 at 6:44
  • 1
    add a password to your user and place the same in database.yml file Commented Jan 3, 2019 at 8:55
  • 1
    you can use pgadmin that comes with postgres can refer to this question stackoverflow.com/questions/9667264/gui-tool-for-postgresql Commented Jan 3, 2019 at 10:30

2 Answers 2

1

You need to install postgresql package into your system you can refer to this link for instruction regarding installing postgres all you need to do is execute the following commands

sudo apt-get install postgresql postgresql-contrib

this installs postgres into your system

then you need to create a user with the details that you have mentioned in the database.yml file of your rails application

You can use pgadmin for db browser you can refer to this question for other tools

to install pgadmin3 run the following command

 sudo apt-get install pgadmin3

then configure it with the details like host port etc that you are using(refer to database.yml)

Sign up to request clarification or add additional context in comments.

Comments

0

You are using gem 'pg' in development group in gem file.

group :development do

    gem 'pg'
    gem 'taps'

end

Include it in every environment by moving this line out of development group.

5 Comments

gd i solve that, now i am confusing with seup pgadmin...EX = in sqllite we just do for open database, open database button/my Documents/app name/db/development.sqlite3 like that in pgadmin how can i open database?
You need to add New Server under file => Add Server. There will be localhost in the list under the server. There you will find you DB.
ya i got it in place of localhost i add host num 127.0.0.1 it work thanks all, for helping me...........
Please accept the answer then to help others as well
@AdarshKL Only accept the answer if it solved your problem, it seemed that Sumanth contributed the most to solve your problem, maybe they will leave an answer based on their comments.

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.