Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1420
  • Last Modified:

Postgresql 9 - psql: could not connect to server: No such file or directory

I have just installed PostgreSQL 9.0.4 on my local machine (ubuntu 10.10), after removing 8.4. Now I want to import a database that is so large that the import in Pgadmin crashes. So I need psql to do this, but when I try, I get the following error:

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

The server seems to be running though, as I can open Pgadmin, create a database, etc. So I wonder if this is different from 8.4? How can I get this working?
1 Solution

Do you know how you configured pgadmin to access the database? You can try to use same configuration for psql. e.g.

psql -hlocalhost -Uusername  database name

If you don't know the username/password,

You can run "ps -elf | grep postmaster" to find out the postgres database process. it should be somthing like

/usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data

Then you need to goto /var/lib/pgsql/data/ folder, modify pg_hba.conf, the reload the postgresql configuration.

for example, add
host    all         root  trust

in pg_hba.conf file, then reload the configuration by "/etc/init.d/postgresql reload"

Then you can login by "psql -hlocalhost database" as root

R7AFAuthor Commented:

psql -hlocalhost -Upostgres
psql -hlocalhost -Upostgres  database_name

(At first I read it like "database" was a parameter name, with the space inbetween database and name.)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now