Testgres cannot allocate a port number 65535, because it uses the range(1024, 65535): https://github.com/postgrespro/testgres/blob/edd64db5284a6b34e275e022a4cc673e1032a6ea/testgres/impl/port_manager__generic.py#L23  I think we have to allow usage of 65535 port number to enlarge our valid range of ports ) The fix is trivial - `set ( range ( 1024 , 65536 )` Another problems in this code will be fixed, too. ### See also https://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html