psql: could not connect to server: No such file or directory Fix

Last day I was reinstalling postgresql on my Ubuntu 12.04 server. I started with normal commands

The installation completed successfully. I was also getting the locale warning message

and as I remembered from before, the fix for this is to add

at the bottom of file /etc/environment. All looked ok, but when I started database

I didn’t get any message. Then when I logged into postgres with

and wanted to create database, I got warning

I checked around and a lot of them mentioned that I had wrong or incomplete settings. Because I didn’t know what to do, I asked around (postgresql channel on freenode) and got really simple solution. I just had to run command

where 9.1 is version of my postgresql database. This recreated settings file and now everything works great.