4. 42 .

When the image set of function $f$ is 1 element, if the image set of function $f$ is $\{1\}$, at this time the image set of function $g$ is a subset of $\{2,3\}$, there are $2^{3}=8$ kinds, so there are $3 \times 8=24$ pairs of functions $(f, g)$ that meet the requirements.

When the image set of function $f$ is 2 elements, if the image set of function $f$ is $\{1,2\}$, at this time $f(1) 、 f(2) 、 f(3)$ have two numbers as 1 and one number as 2, there are $2 \times 3=6$ kinds, so there are $3 \times 6=18$ pairs of functions $(f, g)$ that meet the requirements.
Therefore, the number of function pairs $(f, g)$ is 42 .
4. Given the set $A=\{1,2,3\}, f, g$ are functions from set $A$ to $A$. Then the number of function pairs $(f, g)$ whose images have an empty intersection is $\qquad$ .