TLDR; How to shutdown a solana-test-validator running in the background?

A test I'm running starts a validator with the command

solana-test-validator --reset \
  -q \
  --mint tgyXxAhCkpgtKCEi4W6xWJSzqwVGs3uk2RodbZP2J49 \
  --bpf-program 2uA3amp95zsEHUpo8qnLMhcFAUsiKVEcKHXS1JetFjU5 target/deploy/idl_commands_one.so \
  --bpf-program DE4UbHnAcT6Kfh1fVTPRPwpiA3vipmQ4xR3gcLwX3wwS target/deploy/idl_commands_one.so

At the end of the test it runs

 trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

I had assumed this kills the solana validator and shuts it down but it doesn't and I seemingly have 4 validators running in the background. While I could just kill my terminal, I'd prefer to avoid the nuclear option and know what is the proper way to shutdown solana-test-validators running in the background? (Aside from just killing the process id)

  • Does Ctrl-C work?
    – vicyyn
    Commented Dec 23, 2022 at 12:16
  • no because it's running quietly in the background. I can just kill the program id it's fine but i thought there might be some proper way to do this
    – Henry E
    Commented Dec 23, 2022 at 12:34
  • Maybe check how anchor test does it? Pretty sure it spins up a local validator.
    – Richard
    Commented Dec 24, 2022 at 22:07
  • anchor does start a new local validator for the test but, why are you running the local validator as a background process? it seems like an odd choice to make (as it makes things more difficult) most people run it in a separate terminal window in the foreground since you get easier control
    – nickfrosty
    Commented Jul 19, 2023 at 13:04
  • @nickfrosty It wasn't entirely my choice, running the local validator in the background was part of an existing automated test script for some niche functionality in the anchor repo
    – Henry E
    Commented Jul 24, 2023 at 17:29

1 Answer 1


To shut down a Solana test validator that is running in the background, you can use the following steps:

Open a terminal window and use the ps command to list all the processes running on your system.

ps -aux

Look for the process named solana-test-validator. The output should include the process ID (PID) of the validator.

solana 12345 0.0 0.0 12345 6789 ? Ss 12:34 0:01 solana-test-validator

Use the kill command to send a signal to the validator process, specifying the PID of the process.

kill 12345

This will send a signal to the validator process to shut down. If the validator does not shut down, you can try using the kill -9 command, which will forcefully terminate the process.

kill -9 12345

Keep in mind that shutting down a validator in this way may cause disruptions to any ongoing transactions or processes that are using the validator. It is generally recommended to shut down a validator gracefully, using a command or option provided by the validator software.

  • for sure, as mentioned in the question itself, i know about just killing the process id. I guess I was just surprised there wasn't a cleaner way to do. I will look at how anchor test shuts down its validator though
    – Henry E
    Commented Dec 25, 2022 at 11:23

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.