2021年3月19日星期五

Rails postgresql can't find the database

I'm really lost here, just learning to code and I've come across this issue. It was working fine in a previous app and then suddenly stopped working. I've created new apps and it's just coming up with the same issue again.

The terminal simply can't find the db (postgresql - has to be for assignment).

Any help is incredibly appreciated.

matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ rails db:create  could not connect to server: No such file or directory          Is the server running locally and accepting          connections on Unix domain socket "/tmp/.s.PGSQL.5432"?  Couldn't create 'marketplace_development' database. Please check your configuration.  rails aborted!  ActiveRecord::ConnectionNotEstablished: could not connect to server: No such file or directory          Is the server running locally and accepting          connections on Unix domain socket "/tmp/.s.PGSQL.5432"?  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/rails:5:in `<top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:10:in `block in <top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `tap'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `<top (required)>'    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 "/tmp/.s.PGSQL.5432"?  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/rails:5:in `<top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:10:in `block in <top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `tap'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `<top (required)>'  Tasks: TOP => db:create  (See full trace by running task with --trace)  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ rails db:migrate  rails aborted!  ActiveRecord::ConnectionNotEstablished: could not connect to server: No such file or directory          Is the server running locally and accepting          connections on Unix domain socket "/tmp/.s.PGSQL.5432"?  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/rails:5:in `<top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:10:in `block in <top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `tap'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `<top (required)>'    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 "/tmp/.s.PGSQL.5432"?  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/rails:5:in `<top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:10:in `block in <top (required)>'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `tap'  /mnt/c/Users/mattj/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace/bin/spring:7:in `<top (required)>'  Tasks: TOP => db:migrate  (See full trace by running task with --trace)  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ sudo service postgresql start  [sudo] password for matthew:   * Starting PostgreSQL 10 database server                                                                        [ OK ]  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ su - postgres  Password:  su: Authentication failure  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ su - postgres  Password:  su: Authentication failure  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ psql  psql: error: could not connect to server: No such file or directory          Is the server running locally and accepting          connections on Unix domain socket "/tmp/.s.PGSQL.5432"?  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ which postgres  /home/linuxbrew/.linuxbrew/bin/postgres   matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ rails -v  Rails 6.1.3  matthew@DESKTOP-P54O83M:~/ca/coder-academy/projects/T2/MatthewKennedyT1A2/marketplace$ ruby -v  ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]  
https://stackoverflow.com/questions/66718132/rails-postgresql-cant-find-the-database March 20, 2021 at 12:04PM

没有评论:

发表评论