Added environment validation for hostname and port