Fix error check port when port is not available.