When changing the default port number from 5432 to 5332, why do I get a unix domain socket error?
You may have changed the port for the PostgreSQL database, but not the client.
Try this:

Update your PostgreSQL configuration to use port 5332 again
Test this by passing the port number when trying to connect:
psql -p 5332


If everything works, change the default port for the command-line client like this:
PGPORT=5332; export PGPORT



Now all calls to psql will act as if it has been invoked with the -p 5332 command-line option.