Ahlfors and Beurling [16] proved that set 𝐸 is removable for class 𝐴𝐷2 of analytic functions with the finite Dirichlet integral if and only if 𝐸 does not change extremal distances. Their proof uses the conformal invariance of class 𝐴𝐷2, so it does not immediately generalize to 𝑝 ̸= 2 and to the relevant classes of harmonic functions in the space. In 1974 Hedberg [19] proposed new approaches to the problem of describing removable singularities in the function theory. In particular he gave the exact functional capacitive conditions for a set to be removable for class 𝐻𝐷𝑝(𝐺). Here 𝐻𝐷𝑝(𝐺) is the class of real-valued harmonic functions 𝑢 in a bounded open set 𝐺 ⊂ 𝑅𝑛, 𝑛 ≥ 2, and such that ∫︁ 𝐺 |∇𝑢|𝑝 𝑑𝑥 < ∞, 𝑝 > 1. In this paper we extend Hedberg’s results on class 𝐻𝐷𝑝,𝑤(𝐺) of harmonic functions 𝑢 in 𝐺 and such that ∫︁ 𝐺 |∇𝑢|𝑝 𝑤𝑑𝑥 < ∞. Here a locally integrable function 𝑤 : 𝑅𝑛 → (0,+∞) satisfies the Muckenhoupt condition [20] sup 1 |𝑄| ∫︁ 𝑄 𝑤𝑑𝑥 ⎛ ⎝ 1 |𝑄| ∫︁ 𝑄 𝑤1−𝑞𝑑𝑥 ⎞ ⎠ 𝑝−1 < ∞, where the supremum is taking over all coordinate cubes 𝑄 ⊂ 𝑅𝑛, 𝑞 ∈ (1,+∞) and 1 𝑝 + 1 𝑞 = 1; by ℒ𝑛(𝑄) = |𝑄| we denote the 𝑛-dimensional Lebesgue measure of 𝑄. We denote by 𝐿1 𝑞 , ˜ 𝑤(𝐺) the Sobolev space of locally integrable functions 𝐹 on 𝐺, whose generalized gradient in 𝐺 are such that ‖𝑓‖𝐿1 𝑞 , ˜ 𝑤(𝐺) = ⎛ ⎝ ∫︁ 𝐺 |∇𝑓|𝑞 ˜ 𝑤𝑑𝑥 ⎞ ⎠ 1 𝑞 < ∞, where ˜ 𝑤 = 𝑤1−𝑞. The closure of 𝐶∞ 0 (𝐺) in ‖ · ‖𝐿1 𝑞 , ˜ 𝑤(𝐺) is denoted by ∘L 1 𝑞, ˜ 𝑤(𝐺). For compact set 𝐾 ⊂ 𝐺 (𝑞, ˜ 𝑤)-capacity regarding 𝐺 is defined by 𝐶𝑞, ˜ 𝑤(𝐾) = inf 𝑣 ∫︁ 𝐺 |∇𝑣|𝑞 ˜ 𝑤𝑑𝑥, where the infimum is taken over all 𝑣 ∈ 𝐶∞ 0 (𝐺) such that 𝑣 = 1 in some neighbourhood of 𝐾. Note that 𝐶𝑞, ˜ 𝑤(𝐾) = 0 is independent from the choice of bounded set 𝐺 ⊂ 𝑅𝑛. We set 𝐶𝑞, ˜ 𝑤(𝐹) = 0 for arbitrary 𝐹 ⊂ 𝑅𝑛 if for every compact 𝐾 ⊂ 𝐹 there exists a bounded open set 𝐺 such that 𝐶𝑞, ˜ 𝑤(𝐾) = 0 regarding 𝐺. To conclude, we formulate the main results. Theorem 1. Compact 𝐸 ⊂ 𝐺 is removable for 𝐻𝐷𝑝,𝑤(𝐺) if and only if 𝐶∞ 0 (𝐺 ∖ 𝐸) is dense in ∘L 1 𝑞, ˜ 𝑤(𝐺). Theorem 2. Compact 𝐸 ⊂ 𝐺 is removable for 𝐻𝐷𝑝,𝑤(𝐺) if and only if 𝐶𝑞, ˜ 𝑤(𝐸) = 0. Corollary. The property of being removable for 𝐻𝐷𝑝,𝑤(𝐺) is local, i.e. compact 𝐸 ⊂ 𝐺 is removable if and only if every 𝑥 ∈ 𝐸 has a compact neighbourhood, whose intersection with 𝐺 is removable. Theorem 3. If 𝐺 is an open set in 𝑅𝑛 and 𝐶𝑞, ˜ 𝑤(𝑅𝑛 ∖𝐺) = 0. Then 𝐶∞ 0 (𝐺) is dense in ∘L 1 𝑞, ˜ 𝑤(𝑅𝑛).