diff --git a/apiserver/server_test.go b/apiserver/server_test.go
index <HASH>..<HASH> 100644
--- a/apiserver/server_test.go
+++ b/apiserver/server_test.go
@@ -60,12 +60,15 @@ func (s *serverSuite) TestStop(c *gc.C) {
 	machine, password := s.Factory.MakeMachineReturningPassword(
 		c, &factory.MachineParams{Nonce: "fake_nonce"})
 
+	// A net.TCPAddr cannot be directly stringified into a valid hostname.
+	address := fmt.Sprintf("localhost:%d", srv.Addr().Port)
+
 	// Note we can't use openAs because we're not connecting to
 	apiInfo := &api.Info{
 		Tag:        machine.Tag(),
 		Password:   password,
 		Nonce:      "fake_nonce",
-		Addrs:      []string{srv.Addr().String()},
+		Addrs:      []string{address},
 		CACert:     coretesting.CACert,
 		EnvironTag: s.State.EnvironTag(),
 	}
Fix test stop to specify the address properly.