TITLE: The homotopy category is not complete nor cocomplete
QUESTION [29 upvotes]: I understand that the homotopy category of (pointed) topological spaces and continuous maps is not complete. Nor is it cocomplete. In particular it neither has all pullbacks nor all pushouts.
What are some simple examples of spans $Z\leftarrow X\rightarrow Y$ and cospans $Z\rightarrow X\leftarrow Y$ that cannot be completed to pushout and pullback squares, respectively?

REPLY [6 votes]: Here's an example of missing pullback in the homotopy category of spaces, related to Neil's and Qiaochu's answers. I'll work in pointed spaces, though we'll see that the argument also works in unpointed spaces. Let's say we work in the usual homotopy category (i.e., the localization with respect to weak homotopy equivalences).
Assume that
$$\require{AMScd}
\begin{CD}
P @>>> K(\mathbb{Z},2)\\
@VVV @VV {n} V\\
\ast @>>> K(\mathbb{Z},2)\\
\end{CD}$$
is a pullback in the homotopy category. This says that maps $[X,P]$ consist of the subset of $[X,K(\mathbb{Z},2)]$ of maps becoming null-homotopic after composing with $n \colon K(\mathbb{Z},2) \to K(\mathbb{Z},2)$, in other words, the $n$-torsion in $[X,K(\mathbb{Z},2)]$.
Taking $X = S^0$ yields that $P$ is path-connected. Taking spheres $X = S^i$ yields that $P$ is weakly contractible. In particular, $P$ has the singular cohomology of a point. Now let $\alpha \colon K(\mathbb{Z}/n,1) \to K(\mathbb{Z},2)$ be a generator of $H^2( K(\mathbb{Z}/n,1); \mathbb{Z}) = \mathbb{Z}/n$. The equality $n \alpha = 0$ implies that $\alpha$ factors through $P$. This is a contradiction, since $\alpha$ induces a non-zero map on cohomology $H^2(-;\mathbb{Z})$.
Remark 1. The argument also works in the naive homotopy category (i.e., spaces and homotopy classes of maps). The space $P$ might not have the homotopy type of a CW complex and we don't know that singular cohomology $H^2(P;\mathbb{Z})$ is represented by maps $P \to K(\mathbb{Z},2)$; we only used $H^2(P;\mathbb{Z}) = 0$. For the fact that a weak homotopy equivalence induces an isomorphism on singular (co)homology, see Hatcher Proposition 4.21.
Remark 2: Let's adapt the example to unpointed spaces. Recall that for path-connected $Y$, the forgetful map $[X,Y]_* \to [X,Y]$ from pointed homotopy classes of pointed maps to unpointed homotopy classes of unpointed maps is surjective and induces a bijection $[X,Y] = [X,Y]_* / \pi_1(Y)$ to the set of $\pi_1(Y)$-orbits in $[X,Y]_*$; see Hatcher Proposition 4A.2. In the example above, taking $X = \ast$ yields that $P$ is path-connected. Taking $X = S^1$ yields that $\pi_1(P)$ has only one conjugacy class, hence is the trivial group. The rest of the argument goes through.