configurationsolana

How do I configure the Solana CLI to use a custom RPC endpoint?


I am working with the Solana command-line tools and I need to point them at my own RPC node instead of the default public endpoint. I have tried this:

solana config set --url http://localhost:8899

When I run commands such as solana balance or solana slot they use the default cluster.

  1. How do I verify which RPC endpoint the CLI is targeting?

  2. Switch it to my local endpoint

  3. Ensure solana-keygen picks it up


Solution

  • You can verify your current endpoint by the following command

    solana config get
    

    Look for the RPC URL in the output.

    The command you have tried should work but ensure your validator is actually running on 8899. Use the confirmed flag to ensure the config change is saved.

    solana config set --url http://localhost:8899 --confirmed
    

    solana-keygen reads from the config file located at ~/.config/solana/cli/config.yml

    Using solana config set updates this file. Hope that clarifies your question.