MEM
MEM

Reputation: 31307

First ruby and postgreSql application - getting could not connect to server: No such file or directory

Ruby 1.9.3 on Mac OS X Lion

Followed several posts on SO about this topic. Neither helped.

Trying to run my first rails and postgreSQL app here.

Following this: http://guides.rubyonrails.org/getting_started.html

When I do:

"rake db:create"

I get:

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"?

Some facts:

Not sure what /tmp/ is it referring to but, if it is the one from root, then:

1) Permissions:

drwxrwxrwx 11 root wheel 374B Jan 4 17:33 tmp

2) Also, I see no file .s.PGSQL.5432.

3) I've tried to force the socket location by adding to database.yml the following:

development:
    adapter: postgresql
    encoding: unicode
    database: testblog_development
    pool: 5
    username: blog
    password:
    socket: /var/pgsql_socket # <-- this line

(it stills shows me the same error with the /tmp/ path).

4) When I do, which postgres I get:

/usr/local/bin/postgres 
(I've used homebrew installation)

5) When I do: brew info postgres I get:

postgresql: stable 9.2.2 http://www.postgresql.org/ Depends on: readline, ossp-uuid Conflicts with: postgres-xc /usr/local/Cellar/postgresql/9.2.2 (2819 files, 39M) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/postgresql.rb

and other bunch of information.

Upvotes: 1

Views: 1222

Answers (2)

theIV
theIV

Reputation: 25774

That seems to me like the server isn't running. Do you see anything when you run ps aux | grep postgres from the command line? If all you see is something along the lines of grep postgres in the output, it's not running.

Since you installed PostgreSQL with Homebrew, try brew info postgres for information on how to start up the server if that is indeed the case.

Upvotes: 2

alf
alf

Reputation: 18530

You don't need to specify a socket. Here's a configuration that works for Postgres. You only need to change the database password.

development:
  adapter: postgresql
  host: localhost
  pool: 5
  timeout: 5000
  username: postgres
  password: postgres
  database: testblog_development
  template: template0

Upvotes: 1

Related Questions