Fix bugs in upgrade script.

Handle the case when there are colons in server_name. Handle http
exceptions more gracefully.