Connections via localhost need TCP/IP connections enabled.
Try setting
listen_addresses = * in your postgresql.conf, and restart the server.
Be aware that the whole world can connect to your database then!
As @Bart and @dbenhur commented, the default setting listen_addresses = 'localhost' already covers connections to localhost. This is also true if the setting is commented out.