Find all pairs of nonnegative integers $(x, y)$ for which $(xy + 2)^2 = x^2 + y^2 $.
1. Start with the given equation:
   \[
   (xy + 2)^2 = x^2 + y^2
   \]

2. Expand and rearrange the equation:
   \[
   (xy + 2)^2 = x^2 + y^2
   \]
   \[
   x^2y^2 + 4xy + 4 = x^2 + y^2
   \]
   \[
   x^2y^2 + 4xy + 4 - x^2 - y^2 = 0
   \]

3. Rearrange to isolate terms involving \(x\) and \(y\):
   \[
   x^2y^2 - x^2 - y^2 + 4xy + 4 = 0
   \]

4. Notice that the equation can be rewritten as:
   \[
   x^2y^2 - x^2 - y^2 + 4xy + 4 = 0
   \]
   \[
   x^2(y^2 - 1) + y^2 - 1 + 4xy + 4 = 0
   \]
   \[
   (x^2 - 1)(y^2 - 1) = 4xy + 3
   \]

5. Analyze the equation \((x^2 - 1)(y^2 - 1) = 4xy + 3\):
   - The right-hand side (RHS) is positive, so the left-hand side (LHS) must also be positive.
   - For the LHS to be positive, either both \(x^2 - 1\) and \(y^2 - 1\) must be positive, or both must be negative.

6. Consider the case when \(x = 0\):
   \[
   (0^2 - 1)(y^2 - 1) = 4 \cdot 0 \cdot y + 3
   \]
   \[
   -1 \cdot (y^2 - 1) = 3
   \]
   \[
   y^2 - 1 = -3
   \]
   \[
   y^2 = 2
   \]
   Since \(y\) must be a nonnegative integer, there is no solution in this case.

7. Consider the case when \(y = 0\):
   \[
   (x^2 - 1)(0^2 - 1) = 4 \cdot x \cdot 0 + 3
   \]
   \[
   (x^2 - 1)(-1) = 3
   \]
   \[
   x^2 - 1 = -3
   \]
   \[
   x^2 = 2
   \]
   Since \(x\) must be a nonnegative integer, there is no solution in this case.

8. Consider the case when both \(x\) and \(y\) are non-zero:
   - If \(x = 1\):
     \[
     (1^2 - 1)(y^2 - 1) = 4 \cdot 1 \cdot y + 3
     \]
     \[
     0 \cdot (y^2 - 1) = 4y + 3
     \]
     \[
     0 = 4y + 3
     \]
     This is a contradiction, so no solution exists for \(x = 1\).

   - If \(y = 1\):
     \[
     (x^2 - 1)(1^2 - 1) = 4x \cdot 1 + 3
     \]
     \[
     (x^2 - 1) \cdot 0 = 4x + 3
     \]
     \[
     0 = 4x + 3
     \]
     This is a contradiction, so no solution exists for \(y = 1\).

9. Consider the case when \(x = 2\):
   \[
   (2^2 - 1)(y^2 - 1) = 4 \cdot 2 \cdot y + 3
   \]
   \[
   (4 - 1)(y^2 - 1) = 8y + 3
   \]
   \[
   3(y^2 - 1) = 8y + 3
   \]
   \[
   3y^2 - 3 = 8y + 3
   \]
   \[
   3y^2 - 8y - 6 = 0
   \]
   Solving this quadratic equation:
   \[
   y = \frac{8 \pm \sqrt{64 + 72}}{6}
   \]
   \[
   y = \frac{8 \pm \sqrt{136}}{6}
   \]
   \[
   y = \frac{8 \pm 2\sqrt{34}}{6}
   \]
   \[
   y = \frac{4 \pm \sqrt{34}}{3}
   \]
   Since \(y\) must be a nonnegative integer, there is no solution in this case.

10. Consider the case when \(y = 2\):
    \[
    (x^2 - 1)(2^2 - 1) = 4x \cdot 2 + 3
    \]
    \[
    (x^2 - 1)(4 - 1) = 8x + 3
    \]
    \[
    3(x^2 - 1) = 8x + 3
    \]
    \[
    3x^2 - 3 = 8x + 3
    \]
    \[
    3x^2 - 8x - 6 = 0
    \]
    Solving this quadratic equation:
    \[
    x = \frac{8 \pm \sqrt{64 + 72}}{6}
    \]
    \[
    x = \frac{8 \pm \sqrt{136}}{6}
    \]
    \[
    x = \frac{8 \pm 2\sqrt{34}}{6}
    \]
    \[
    x = \frac{4 \pm \sqrt{34}}{3}
    \]
    Since \(x\) must be a nonnegative integer, there is no solution in this case.

11. Therefore, the only solutions are when \(x = 0\) and \(y = 2\) or \(x = 2\) and \(y = 0\).

Conclusion:
\[
\boxed{(0, 2) \text{ and } (2, 0)}
\]