简体   繁体   中英

Rails db:create using PostgreSQL return PG::ConnectionBad: could not connect to server: Connection refused

I was following the tutorial to develop using react and rails from the DigitalOcean Tutorial .

I have done

rails new rails_react_recipe -d=postgresql -T --webpack=react --skip-coffee

It created the directory with all the necessary tools - ruby and rails. Then the next step is to create the database

rails db:create

but it returned me the error below

could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
Couldn't create 'rails_react_recipe_development' database. Please check your configuration.        
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)

I have installed postgresql 12 for windows from https://www.postgresql.org/download/

I couldn't find any solution online. Help will be really appreciated. Thanks!

You need to start the Postgres server for it to start accepting connections. Currently, you've probably downloaded Postgres, but not started it.

You could follow instructions here to learn how to start it on Windows: https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgresql-server.html

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