Getting this error while trying to run my tests cases with anchor

Error: failed to get recent blockhash: TypeError: fetch failed
    at Connection.getLatestBlockhash (/home/jimii/Documents/crew/stream-nft/node_modules/@solana/web3.js/src/connection.ts:4593:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at AnchorProvider.sendAndConfirm (/home/jimii/Documents/crew/stream-nft/node_modules/@coral-xyz/anchor/src/provider.ts:147:9)
    at MethodsBuilder.rpc [as _rpcFn] (/home/jimii/Documents/crew/stream-nft/node_modules/@coral-xyz/anchor/src/program/namespace/rpc.ts:29:16)
      ✔ Admin initializes the protocol sate (860ms)

Not sure why the RPC call is failing given that airdrop and deploying the program still works on my machine.

  • This is strange... what versions are you using for web3.js, Anchor, and your test validator? I wonder if it's trying to call the old getRecentBlockhash endpoint
    – Jon C
    Commented May 1 at 9:33
  • My environment solana-cli 1.17.28 && anchor-cli 0.29.0. In my package.json "@solana/web3.js": "^1.91.7", && "@coral-xyz/anchor": "^0.29.0",. I also raised the error on the anchor repo but was closed because I cannot reproduce it.
    – Jimii
    Commented May 1 at 10:13

1 Answer 1


on, Linux Pop OS. Fixed the error by changing my DNS to point to the Google DNS server.

Start the resolvconf service if it's not on

sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service

Check the status

sudo systemctl status resolvconf.service

enter image description here

Update your DNS configuration resolveconf/head to point to Google's DNS servers.

Open the file

sudo nano /etc/resolvconf/resolv.conf.d/head

add add


Update resolv.conf

sudo resolvconf --enable-updates
sudo resolvconf -u

Restart the corresponding services

sudo systemctl restart resolvconf.service
sudo systemctl status systemd-resolved.service

guide: https://www.ionos.com/digitalguide/server/configuration/change-dns-server-on-ubuntu/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.