There was a problem connecting to the server "localhost"

If right after unlocking a vault, Finder shows an error as shown in the screenshot with the following message in the log file (depending on your system language):

An error of type -5014 has occurred. (-5014)
Es ist ein Fehler „-5014“ aufgetreten. (-5014)
Une erreur de type -5014 est survenue. (-5014)

This error usually means that your machine is unable to create a loopback connection, i.e. can’t resolve localhost. To fix this, please make sure your config file /etc/hosts contains both of the following lines:

127.0.0.1 localhost
::1 localhost