Updated server connection to database to wait for a connection before continuing to avoid TTL errors.