How to limit rotation on the last bone of an ik chain
The Chain Length of the Inverse Kinematics constraint is including the bone that has that constraint. In your case the value is 3, so it applies to Bone7, Bone6 and Bone5. Therefor Bone4 is not part of the the IK setup and it's rotation behavior cannot be limited by the Inverse Kinematics settings in the Bone Properties.
You can increase the value of the Chain Length to include Bone4. (Or put a Limit Rotation bone constraint on it in the Bone Constraint Properties tab if you don't want it to be part of the chain.)
Also when Relationship Lines are active (which can be made visible by checking the box in the Overlays menu), you can see a line from the start to the end of the chain that can help determine the length in the 3D Viewport.
Edit:
Note that if the box next to Use Tail is not checked, the bone that has the Inverse Kinematics constraint, is not part of the chain. However in this case that bone (otherwise first in the chain) is not affected by inverse kinematics, and (more importantly) the last bone in the chain cannot be constrained in the Bone Properties &gt; Inverse Kinematics menu.