Fix bug to ensure port is defined.