Optimisation of createRegistry to prevent 'Port already in use'