# [SOLVED] problems connecting to postgresql

## slackline

Hi

I'm attempting to install postgresql and am following the Gentoo Wiki PostgreSQL guide verbatim.

I've configured internal connections as per the guide, but when I come to start and test the db I get...

```

haldane db # /etc/init.d/postgresql start

 * Caching service dependencies ...                                                                                              [ ok ]

 * Starting PostgreSQL ...                                                                                                       [ ok ]

haldane db # psql -U postgres -l

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

```

There is nothing appearing in the log giles (set to be /var/log/pgsql/ as per the guide).

Can anyone suggest how I find out whats going on?  Any insights as to how to solve this would be appreciated.

Thanks

slackLast edited by slackline on Wed Jun 20, 2007 4:01 pm; edited 1 time in total

----------

## limn

Likely postgresql is dying immediately after starting. Check to see that the /tmp/.s.PGSQL.5432 file exists. Also check for the process:

```
ps -ef | grep postmaster
```

Try starting the postmaster from the command line as user postgres

```
postmaster -D /var/lib/postgresql/data
```

to see if it complains in a meaningful way. Change /var/lib/postgresql/data to point to your data directory if necessary.

----------

## slackline

 *limn wrote:*   

> Likely postgresql is dying immediately after starting. Check to see that the /tmp/.s.PGSQL.5432 file exists. Also check for the process:
> 
> ```
> ps -ef | grep postmaster
> ```
> ...

 

Sussed  :Very Happy: 

The /tmp/.s.PGSQL.5432 wasn't there (had already checked), and the process wasn't starting so your prognosis was correct, postgresql was indeed dying.

The clue was provided by your suggestion to use postmaster as user postgres...

```

postgres@haldane $ postmaster -D /var/lib/postgresql/data

2007-06-20 16:48:43 BSTFATAL:  could not create log file "/var/log/pg_log/postgresql-2007-06-20.log": No such file or directory

```

A quick check and sure enough I'd made a typo in /var/lib/postgresql/data/postgresql.conf (quite how I got a typo of an underscore in there I've no idea, other than I'm a muppet).

This solves everything, the init script starts without any problem and I can list the databases (as user postgres).

Onwards and upwards to user and db creation  :Smile: 

Thanks for taking the time to help with this,

slack

----------

## Digedag

I have got the same problem but for me it still doesn't work.

```
localhost conf.d # /etc/init.d/postgresql start

 * Starting PostgreSQL ...

LOG:  could not bind IPv4 socket: Cannot assign requested address

HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

LOG:  could not bind IPv6 socket: Cannot assign requested address

HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

WARNING:  could not create listen socket for "localhost"

FATAL:  could not create any TCP/IP sockets                               [ !! ]

localhost conf.d # su postgres

postgres@localhost /etc/conf.d $ postmaster -D /var/lib/postgresql/data

LOG:  could not bind IPv4 socket: Cannot assign requested address

HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

LOG:  could not bind IPv6 socket: Cannot assign requested address

HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

WARNING:  could not create listen socket for "localhost"

FATAL:  could not create any TCP/IP sockets

postgres@localhost /etc/conf.d $ exit

exit

localhost conf.d # ps -ef | grep postmaster

root      6172  4327  0 17:29 pts/0    00:00:00 grep --colour=auto postmaster

localhost conf.d # psql -U postgres

psql: could not connect to server: Connection refused

        Is the server running locally and accepting

        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

```

Does anyone have an idea how to fix this?

----------

## Digedag

the following works by me

```
postgres@localhost / $ postmaster -D /var/lib/postgresql/data -i

LOG:  could not bind socket for statistics collector: Cannot assign requested address

LOG:  could not bind socket for statistics collector: Cannot assign requested address

LOG:  disabling statistics collector for lack of working socket

LOG:  database system was shut down at 2007-09-23 18:29:01 CEST

LOG:  checkpoint record is at 0/390368

LOG:  redo record is at 0/390368; undo record is at 0/0; shutdown TRUE

LOG:  next transaction ID: 565; next OID: 10794

LOG:  next MultiXactId: 1; next MultiXactOffset: 0

LOG:  database system is ready

LOG:  transaction ID wrap limit is 2147484146, limited by database "postgres"

```

but I still can't use the script in /etc/init.d

----------

