add validation for port values to server (fix #3227)