You will get this error if you try to connect(2) a socket(2) to a host, and a router between you and that host believes the host is unreachable. It would then send ICMP_DEST_UNREACH, which would find its way back to you eventually.

You would also see this instantly if for example your local machine knew it had no route to the destination host.