Fix for connection errors when using replication

Closes #1292