In this paper, we consider the following variational problem: \(\begin{aligned} \inf _{u\in D^{1,2}_a(\mathbb {R}^N)\backslash \mathcal {Z}}\frac{\Vert u\Vert ^2_{D^{1,2}_a(\mathbb {R}^N)}-C_{a,b,N}^{-1}\Vert u\Vert ^2_{L^{p+1}(|x|^{-b(p+1)},\mathbb {R}^N)}}{\inf _{v\in \mathcal {Z}}\Vert u-v\Vert ^2_{D^{1,2}_a(\mathbb {R}^N)}}:=c_{BE}, \end{aligned}\) where \(N\ge 2\) , \(\begin{aligned} \left\{ \begin{aligned}&b_{FS}(a)<b<a+1,\quad a<0,\\&a\le b<a+1,\quad 0\le a<a_c:=\frac{N-2}{2}\text { and }a+b>0 \end{aligned}\right. \end{aligned}\) with \(b_{FS}(a)\) being the Felli–Schneider curve, \(p=\frac{N+2(1+a-b)}{N-2(1+a-b)}\) , \(\begin{aligned} \mathcal {Z}= \{ c \tau ^{a_c-a}W(\tau x)\mid c\in \mathbb {R}\backslash \{0\}, \tau >0\} \end{aligned}\) and up to dilations and scalar multiplications, W(x), which is positive and radially symmetric, is the unique extremal function of the following classical Caffarelli–Kohn–Nirenberg (CKN for short) inequality \(\begin{aligned} \bigg (\int _{\mathbb {R}^N}|x|^{-b(p+1)}|u|^{p+1}dx\bigg )^{\frac{2}{p+1}}\le C_{a,b,N}\int _{\mathbb {R}^N}|x|^{-2a}|\nabla u|^2dx \end{aligned}\) with \(C_{a,b,N}\) being the optimal constant. It is known in Wei and Wu (Math Ann 384:1509–1546, 2022) that \(c_{BE}>0\) . In this paper, we prove that the above variational problem has a minimizer for \(N\ge 2\) under the following two assumptions: (i) \(a_c^*\le a<a_c\) and \(a\le b<a+1\) , (ii) \(a<a_c^*\) and \(b_{FS}^*(a)\le b<a+1\) , where \(a_c^*=\bigg (1-\sqrt{\frac{N-1}{2N}}\bigg )a_c\) and \(\begin{aligned} b_{FS}^*(a)=\frac{(a_c-a)N}{a_c-a+\sqrt{(a_c-a)^2+N-1}}+a-a_c. \end{aligned}\) Our results extend that of König (J Eur Math Soc. arXiv:2211.14185v3 [Math. AP]) for the Sobolev inequality to the CKN inequality.