Suppose we take a long and tightly wound solenoid with current I going in it. We can find the field inside, by ampere's law, taking a rectangular loop and assuming the magnetic field just outside the solenoid is 0.
However if we take a circular loop around the solenoid, then:
$\int \mathbf{B}\cdot d\mathbf{r} = 0$ as the field outside the solenoid is 0, but current passing through the loop is not 0. The current is entering at a near-90 degree angle, but it passes through the loop(as charge comes from left side, it must exit through the loop through the right side).
Since the angle at which the current goes through the loop does not matter in Ampere's law, we will still count that "I" current passes through the loop. This means that Ampere's law is not working, as current is passing through the loop, but $\int\mathbf{B}\cdot d\mathbf{r} = 0$.
Why isn't Ampere's law working in the above case?