It is difficult to obtain satisfactory anesthesia in the presence of infection near the injection site because

acidity of the infected tissue inhibits action of the anesthetic agent.

alkalinity of the infected tissue inhibits action of the anesthetic agent

increased blood supply carries the anesthetic solution away too fast

the swelling causes increased pressure on the nerves.