Allowing empty hostname when using postgres.

fixes #437
Check if key's len is valid or not.

fixes #451