I run this:

$ postgres -D foobar

It just hangs. There is no error message. I newly created this database with the initdb command. What should I do?

  • 3
    It doesn't "hang". From the manual: "By default postgres starts in the foreground" - so your command starts it in the foreground and thus your console is "blocked". It's better to use pg_ctl to start it in the background or use the wrapper script provided by your Linux distribution (e.g. service postgresql start) – a_horse_with_no_name May 7 '15 at 5:51
  • Which distribution of Linux are you using? You may find it preferable to install from a distribution-specific repository. – Colin 't Hart May 7 '15 at 9:05

From the INSTALL document

                                Short Version

make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test


initdb initialises the system after the binaries have been put in place, either through an rpm or a source compile.

postgres launches the server (which is what you're trying to do)

createdb xyz creates a database of name xyz

psql is the command-line client

You could try

./bin/pg_ctl -D ./data/ -l logfile start

On running initdb, you should have received a message


Success. You can now start the database server using:

./bin/postgres -D ./data/


./bin/pg_ctl -D ./data/ -l logfile start


What I can suggest to you is to run the pg_ctl option - it's the one that I use, for what it's worth.

You appear to have confused the server command with a database access command. You should run psql foobar to access the foobar database, provided the server is already running - see above how to do that.

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.