Added error checking & fixed connection bug

Cannot use 127.0.0.1 to connect to port on local machine