Hi this is my first time for a few things. I am trying to get rails
working with postgres-9.0.1, I have never used postgres before. I do
know the server is listening on localhost:5432 as I am able to connect
to it using pgadmin3 and see the 2 databases on it.
I have 'pg' gem installed
my database.yml looks like this
yadav@expression:$ rake db:migrate --trace
(in /home/yadav/dev/rails/tmp/testapp)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
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"?
Hi this is my first time for a few things. I am trying to get rails
working with postgres-9.0.1, I have never used postgres before. I do
know the server is listening on localhost:5432 as I am able to connect
to it using pgadmin3 and see the 2 databases on it.
I have ‘pg’ gem installed
my database.yml looks like this
development:
adapter: postgresql
encoding: unicode
database: test
pool: 5
username:
password:
however i am getting the following migrate error
yadav@expression:$ rake db:migrate --trace
(in /home/yadav/dev/rails/tmp/testapp)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
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"?
It might help if you can post your database.yml… also, have you created
your databases (rake db:create:all)?
Hi David,
thanks for the tip, I got it working, just had to add "host:
localhost" as Philip pointed out.
Cool… hey if you have a chance let me know if you can connect to the db using: “rails dbconsole”… I have never been successful doing this and I just go to the postgresql command line but would be curious if it works for you… I can connect no problem to the rails console, but for whatever reason I get “Couldn’t find database client: psql. Check your $PATH and try again.” when I try rails dbconsole.
>
>
>>
>> Hi this is my first time for a few things. I am trying to get rails
>> working with postgres-9.0.1, I have never used postgres before. I do
>> know the server is listening on localhost:5432 as I am able to
connect
>> to it using pgadmin3 and see the 2 databases on it.
>>
>> I have 'pg' gem installed
>> my database.yml looks like this
>>
>> development:
>> adapter: postgresql
>> encoding: unicode
>> database: test
>> pool: 5
>> username:
>> password:
>>
>> however i am getting the following migrate error
>>
>> yadav@expression:$ rake db:migrate --trace
>> (in /home/yadav/dev/rails/tmp/testapp)
>> ** Invoke db:migrate (first_time)
>> ** Invoke environment (first_time)
>> ** Execute environment
>> ** Execute db:migrate
>> rake aborted!
>> 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"?
>
> It might help if you can post your database.yml.... also, have
you created
> your databases (rake db:create:all)?
>
Hi David,
thanks for the tip, I got it working, just had to add "host:
localhost" as Philip pointed out.
Cool… hey if you have a chance let me know if you can connect to the
db using: “rails dbconsole”… I have never been successful doing this
and I just go to the postgresql command line but would be curious if it
works for you… I can connect no problem to the rails console, but for
whatever reason I get "Couldn’t find database client: psql. Check your
$PATH and try again." when I try rails dbconsole.
Hi David,
‘rails dbconsole’ works for me. Are you on Linux? if so what do you get when you do a ‘which psql’, do you get the right path?
Well, I am on a Mac, and interesting, when I ask for ‘which psql’ it does not return anything. And if I type psql into the terminal I get “command not found”. So must be that I need to assign the path… I have just been lazy. I just rebuilt my computer so I’ll have a look at doing this.
rake aborted!
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"?
It is looking for the domain socket in
/var/run/postgresql/.s.PGSQL.5432.
Go in /var/run/postgresql/ and
ln -s wherever/your/domain/socket/is/.s.PGSQL.5432 .
You can find the socket with a global search, like
find / -name .s.PGSQL.\*
The above will fix the issue, but a more definitive solution would be to
point rails to the right location of the domain socket (I am just
looking how to do it myself!)
By default PostgreSQL listens on a local domain socket for security reasons, however, by adding the host: localhost line you are telling the PostgreSQL driver that you want to use TCP networking, and so it switches to TCP/IP connections on port 5432.
The fact that use use localhost to connect to the local machine is irrelevant you can put any IP address there to connect to a PostgreSQL instance anywhere on the Internet