Fix when reusing the base_dir and connecting too fast

I found out that if I decide to use already set up base_dir and than skipping setup() the connection will fail because postmaster hasn't fully started yet.

I am not sure if waiting and retrying is the right approach, but it works in my case.