Hello. I got a problem only on mainnet-beta. Everything is working fine on devnet.

Right after my connection.sendTransaction, I'm doing a connection.confirmTransaction this way:

   const latestBlockHash = await connection.getLatestBlockhash();
   await connection.confirmTransaction(
         blockhash: latestBlockHash.blockhash,
         lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,

But my confirmTransaction is taking forever (at least a minute), throwing this error infinitely every 1 sec: ws error: received bad response code from server 401, until this next one is thrown:

ERROR: confirmTransaction >  [TransactionExpiredBlockheightExceededError: Signature xxxxxxxxxx has expired: block height exceeded.]

and then it finally works! (except that I still have the error ws error: received bad response code from server 401 popping in my terminal, even though my transaction worked)

I'm not sure why it's throwing this error and why it's taking that long! In devnet, everything works in 3-4 sec without any error.

I'm using the lib in React-Native, I'm not sure it's relevant, but it's worth mentioning :)

Thank you in advance for your help.

2 Answers 2


Error 401 means "unauthorized", so it appears that the RPC endpoint that you're using doesn't authorize you for websockets. This means that the client doesn't see the transaction get confirmed, and spends the maximum amount of time waiting before throwing an error, since it still never saw the confirmation.

This is an issue with the RPC nodes. Your options are to get a dedicated RPC node for your project, or change up the confirmation logic to avoid websockets, with getSignatureStatus. Note that this isn't a great solution, since polling produces a bigger load on RPC than a websocket.


Which RPC endpoints are you using? It could be that your mainnet RPC is not supporting websockets.

Grab one dedicated Helius or Shyft RPC endpoint for free, they support wss.


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.