I installed postgresql in ubuntu but I am unclear how to start or configure it for a local server (apache)

I tried typing (at the terminal prompt)


but I am getting this error message:

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

I'm used to mysql where you can just type

mysql -u username -p password

I also just tried re-installing postgresql, this is my error message:

Setting up postgresql-9.1 (9.1.3-0ubuntu0.11.10) ...
 * Starting PostgreSQL 9.1 database server                                       * The PostgreSQL server failed to start. Please check the log output:
2012-03-05 10:57:06 EST LOG:  invalid connection type "localhost"
2012-03-05 10:57:06 EST CONTEXT:  line 76 of configuration file "/etc/postgresql/9.1/main/pg_hba.conf"
2012-03-05 10:57:06 EST LOG:  invalid connection type "METHOD"
2012-03-05 10:57:06 EST CONTEXT:  line 100 of configuration file "/etc/postgresql/9.1/main/pg_hba.conf"
2012-03-05 10:57:06 EST FATAL:  could not load pg_hba.conf
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-9.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of postgresql:
 postgresql depends on postgresql-9.1; however:
  Package postgresql-9.1 is not configured yet.
dpkg: error processing postgresql (--configure):
 dependency problems - leaving unconfigured
  • Is PostgreSQL running? – Karlson Mar 5 '12 at 15:35
  • I just tried to start it using : postgres -D /usr/local/pgsql/data and I get the message No command 'postgres' found, did you mean: – nicole Mar 5 '12 at 15:45
  • That's not how you start it. Do you have root or sudo access to run something as user postgres? – Karlson Mar 5 '12 at 15:57

Normally before you go check anything else I'd check whether or not the PostgreSQL is even running:

ps -fu postgres

If it is running you will need to edit /etc/postgres/postres.conf, /etc/postgres/pg_hba.conf to get this configured properly.

You can see this page for more details.

If the server is not running the you might have to try and start it:

sudo /etc/init.d/postgresql-<version> restart

If the problem continues then I'd start checking logs to troubleshoot.

  • I tried running the first command I got this message: – nicole Mar 5 '12 at 16:06
  • UID PID PPID C STIME TTY TIME CMD – nicole Mar 5 '12 at 16:06
  • @nicole That means that the database engine is not running. You will have to start it and if it doesn't start configure it and then start it. – Karlson Mar 5 '12 at 16:10

The problem is that the PostgreSQL has stopped so must start it. Try the below command for starting the PostgreSQL:

To check the status:

sudo /etc/init.d/postgres status

To start:

sudo /etc/init.d/postgresql start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.