Andrey Dmitriev wrote: And Postgres is indeed running on your local machine on that port?
Yes. Application and database mounted on one and the same server with host: remotehost.com.
TCP-connrction between them is posible, but will be not so fast as by unix-socket
I think you are confused about how the network stack works. If you do not provide a hostname on the JDBC URL, then localhost is assumed. Localhost requests are tied (routed) to the loopback network device because that's how the network stack is implemented.
However, if you are going to access a PostgreSQL server on localhost, you need to make sure that there is in fact a PostgreSQL server running on the localhost, that it has been configured to listen on the proper ports (5432 by default), that there are no intervening firewall rules blocking you and that finally, that the user authentication mechanism that you are using to contact the database is valid for that set of credentials, that contact source and that database. PostgreSQL is quite paranoid.
Some of these restrictions do no apply when using Unix-domain sockets instead of TCP. However unless you are moving large amounts of data in a single transaction, Unix-domain sockets may not give as much of a boost as hoped for over TCP. And, of course, you do have to have the PostgreSQL server configured properly for Unix-domain sockets. And be running a relatively recent JDBC driver, since this wasn't even an option until PostgreSQL 9.4-1208.
Unix-domain sockets do have a performance advantage, but they also limit you. They only work on the local machine, and in today's virtualized and containerized world, that may not be good enough. It's not uncommon to have a completely separate physical host(s) for a high-performance database installation. And as far as I know, you cannot at this time do domain sockets between containers and containers are very popular as elastic services for webapp servers and other processes. The current mood is that it's better to throw more machines at a problem than to tune fewer ones because hardware is cheap but specialized labor isn't.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!