Ubuntu – psql: FATAL: could not write init file

postgresqlUbuntu

as the title points out, I'm getting this error when trying to connect to a PostgreSql database from command line, using PostgreSQL.

The client machine is an Ubuntu 11.10 x86_64 and the PostgreSQL libraries are from Version 9.1

Server is PostgreSql 8.3.

This is the command that I executed:

psql -U postgres -d my_database -h 192.168.0.161 -p 5432 -c "select * from xxyy"

I get the same results when I use sudo or su postgres.

The sad thing is that I can connect without problems using pgAdmin.

Any hint?

Best Answer

I had the same issue earlier.

Upon checking the log, I saw that postgres was complaining about diskspace. A df -h showed that the device had 0MB free space available. After freeing up some space, it worked.