fix segfault when running out of ports