Is there any more solution can be taken to avoid this?
Usually when bitcoin.core is downloaded for download, it is downloaded directly to the
C drive. The correct solution is to download Bitcoin Core directly to the
C drive and install it. This is usually a LND login with which credentials/cookies and Bitcoin Core is running in which data
D cookies/configs. You need to make sure where it is running.
Solving problems using cookies:1: (Bitcoin Core Running)+(.cookie) file stores temporary (RPC) credentials. Make sure LND knows about the (RPC) file inside (.cookie). After downloading bitcoin core, (C/D) can detect.. (.cookie) from wherever it is.
2: (lnd.conf) must be completely cleared to make sure where (cookie/data) is and whether it can be detected.
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
bitcoind.dir=D:\Bitcoin\Data
bitcoind.rpchost=127.0.0.1
bitcoind.rpccookie=D:\Bitcoin\Data\.cookie
And you must note that if bitcoind.dir, bitcoind.rpccookie are in the main dock of LND, if Core is on the default (C:) drive and if you show LND the (D:) drive, or vice versa, then 401 will come, it is normal. So you must be sure whether (bitcoind.dir/bitcoind.rpccookie) works correctly.
RPCUSER/RPCPASSWORD:(rpcuser/rpcpassword) should be used correctly to keep conflicts free. (bitcoin.conf and ind.conf) If the user/password does not match, this can cause 401 errors.
You can use the other words without these three symbols
(",#,=). However, using them will cause problems with conf passing.
Bitcoin.conf (Core)server=1
txindex=1
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
rpcauth=youruser:...<hashed-secret>...
lnd.confbitcoind.rpcuser=youruser
bitcoind.rpcpass=the_plain_password_you_generated
ZMQ/RPCPOLLING: If you can connect ZMQ properly, there will be no problem. If there is a problem with the ZMQ config, you can use RPCPOLLING to find the cookie easily.
(D: Datad, Cookie-meaning):bitcoin.confserver=1
txindex=1
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
# (ZMQ if not used then no need this.)
# zmqpubrawblock=tcp://127.0.0.1:28332
# zmqpubrawtx=tcp://127.0.0.1:28333
lnd.confbitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
Bitcoind:
bitcoind.dir=D:\Bitcoin\Data
bitcoind.rpchost=127.0.0.1:8332
bitcoind.rpccookie=D:\Bitcoin\Data\.cookie
bitcoind.rpcpolling=1
Where you have LND installed doesn't matter, what matters is which data the cookie/config is being read from. It worked after you installed it on C:, because then LND and Core probably found the same default directory (.cookie/conf). If you set the correct (bitcoind.dir/bitcoind.rpccookie) it will work fine even if it is on D:. (Lightning Engineering Docs), (Bitcoin Stack Exchange)
If you want, you can paste the relevant part of your current (bitcoin.conf/lnd.conf) here (with the path/password hidden), and your problem will be solved.