Ask A Question

Notifications

You’re not receiving notifications from this thread.

error in rake db:create command

Francisco Morales Sánchez asked in Ruby

Hi everyone

I'm getting this error when I try to create db (I've guided me with https://gorails.com/setup/windows/10). Using WSL.
All step go well, till this command: rake db:create

could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'myapp_development' database. Please check your configuration.
rake aborted!
ActiveRecord::NoDatabaseError: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tasks: TOP => db:create
(See full trace by running task with --trace)

Thanks for your help

Reply

Like the error says, your postgres server is not running. You need to start your postgres server and then it can connect.

Reply

Hi Chris

Thanks for your comment.
I've run posgresql service and in other console of ubuntu I run command rake db:create, and I get the same message.
Maybe I neccessary need to create the database first such as in laravel would do? or I'm in the wrong route?.
I only need solve this issue to start with RoR.

Here the consoles
(Postgresql service)
This message is shown once a day. To disable it please create the
/home/ubuntu/.hushlogin file.
ubuntu@LAPTOP-MIO8EIGO:~$ sudo service postgresql start
[sudo] password for ubuntu:

  • Starting PostgreSQL 12 database server [ OK ] ubuntu@LAPTOP-MIO8EIGO:~$ sudo -u postgres psql psql (12.8 (Ubuntu 12.8-0ubuntu0.20.04.1)) Type "help" for help.

postgres=#

RoR app
ubuntu@LAPTOP-MIO8EIGO:/mnt/c/code/myapp$ rake db:create
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'myapp_development' database. Please check your configuration.
rake aborted!
ActiveRecord::NoDatabaseError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tasks: TOP => db:create
(See full trace by running task with --trace)
ubuntu@LAPTOP-MIO8EIGO:/mnt/c/code/myapp$

thank you

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.