the issue seams to have been caused by having multiple connection files defined for your site. and having one of them misconfigured for connecting to the remote database.
it is recommended to have only one connection file for your site to limit issues that may occur from selecting the wrong connection.