5

I'm trying to setup a rails environment development on a Windows 10.

I follow the tutorial of 'go_rails' (https://gorails.com/setup/windows/10)

Most of the installation seems to worked fine (when i type rby -v or rails -v in the bash it's return the expected result).

My issue is with postresql which is used for the project i work on it.

Following the instructions of the tutorial i install Postgresql (10) directly on Windows. It's seems to work since in can login using the pgadmin on windows or by typing 'psql -p 5432 -h localhost -U postgres' in the bash.

So it's look like postgresql is working, but when i do a rake db:create in bash, i got an error : could not connect to the server: No such file or directory. Is the server running locally and accepting connections on Unix domain socket '/var/run/postgresql/.s.PGSQL.5432'

In the postgresql.conf (C:/Programms/.../Data/postgresql.conf) the listen_addresses is set to '*'.

A bit after there is a line named '#unix_socket_directoris = ''', do you thing i should set something in there?

I really need to get that project work.

Thanks for your help

3 Answers 3

4

The problem is likely that you've installed the Windows binary for PostgreSQL, but you're trying to connect to it from Windows Subsystem for Linux using a Unix socket, which doesn't exist.

You need to use TCP/IP to connect rather than a Unix socket. When typing psql on the command line, add the option --host=127.0.0.1 to connect via TCP/IP.

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

2 Comments

Should we also then set in database.yml host: localhost or host: 127.0.0.1.
Any follow up in this solution?
2

I just went through the entire Go Rails tutorial and I also had trouble at the rake db:create step. All you need to do is add host: 127.0.0.1 to your database.yml as shown below. Make sure to Start PostgreSQL before you run rake db:create.

default: &default
  host: 127.0.0.1
  adapter: postgresql
  encoding: unicode
  username: postgres
  password: ENV['POSTGRESQL_PASSWORD']
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: app_development

test:
  <<: *default
  database: app_test

production:
  <<: *default
  database: app_production
  username: app_username
  password: <%= ENV['APP_DATABASE_PASSWORD'] %>

Comments

0

Add host: localhost to your default: in database.yml. Without something telling rails where to look for the host, it looks for the process in linux, which, of course, won't work, since windows processes are not exposed to the wsl layer.

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.