diff --git a/pkg/machine/apple/vfkit/helper.go b/pkg/machine/apple/vfkit/helper.go index 47a3c98bf6..cc3a22efb4 100644 --- a/pkg/machine/apple/vfkit/helper.go +++ b/pkg/machine/apple/vfkit/helper.go @@ -83,7 +83,9 @@ func (vf *Helper) stateChange(newState rest.StateChange) error { } payload := bytes.NewReader(b) serverResponse, err := vf.post(vf.Endpoint+state, payload) - _ = serverResponse.Body.Close() + if err == nil { + _ = serverResponse.Body.Close() + } return err }