dimanche 5 février 2023

rails problem : "connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory ..."?

I am newbie with rails and here is my problem.

I made a very simple rails program and at the first time I ran this program, it worked perfectly.

But at the second time, It gave me this error :

connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?

As you can see in this picture

my problem

I referenced this stackoverflow's question Rails | connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory And as the answer, I added the 2 lines to the database.yml and ran the command : bundle install

default: &default
...
host: <%= ENV.fetch('DATABASE_HOST', 'localhost') %>
port: <%= ENV.fetch('DATABASE_PORT', 5432) %>

But it gave me another error

Puma caught this error: Cannot load database configuration:
YAML syntax error occurred while parsing 
/Users/xxx/Desktop/Rails/freelancer/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): mapping values are not allowed in this context at line 90 column 7 (RuntimeError)

So could you please give me some advices to solve this problem ? Here is my program for reference.

https://github.com/nguyencuc2586/freelancer01

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire