If the unix socket should be used, it should be explicitly, not by having an exception occur when the host/port fails to find the host/port. Why not test to see if the host/port is set, then see if the unix_socket is set and use it?
My concern with this path of fallback is if there's a key error looking for the path here, and should something explode it won't be obvious when using it why the config was bad.