Fix bug on connect() failure