Add exception handling about main port check