Avoiding a tragedy, a man is recovering at a local hospital after accidentally shooting himself while cleaning a gun.

Police said a man was drinking a beer as he was cleaning a gun at his home in the 600 block of Berkshire Road at around 8:45 p.m. Monday.

Police said the gun accidentally discharged and grazed the man on his hip.

The man was rushed to a hospital by his wife, but were pulled over by officers at 24th and H streets. Officers then drove the man the rest of the way to San Joaquin Community Hospital.

The man was then taken to Kern Medical for further treatment.

Police said the man won’t face charges and no one else was wounded.