Solana Anchor framework: Can't connect to localhost and therefor not deply to it

Viewed 1072

Anchor deploy Deploying workspace: http://localhost:8899 Upgrade authority: /home/tomcatzy/.config/solana/id.json Deploying program "basic-1"... Program path: /home/tomcatzy/projects/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so... Error: RPC request error: cluster version query failed: error sending request for url (http://localhost:8899/): error trying to connect: tcp connect error: Connection refused (os error 111) There was a problem deploying: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "" }.

solana config set --url http://localhost:8899 (Is this enough to start the localhost ?) solana-keygen new solana-test-validator

It seems strange that after a succesful anchor build that i can't do a anchor deploy with the solana command lines ran above. If by any means 'need' to run a - npm init - then where to do it ?trying to deploy a workspace  to a localhost

solana config set --url http://localhost:8899 (Is this enough to start the localhost ?) solana-keygen new solana-test-validator

I tried the above and got generated a keypair: keyname_1-keypair.json. The build went succesful but the deploy not !

I'm wondering why not ?

Hopefully some can guide me what to get it succed...

3 Answers

In a separate window / terminal, you need to run solana-test-validator so that the tools can talk to your local network. The error you're seeing on deployment is due to an error on connecting to that network.

enter image description here

By following the Solana docs and doing this

sudo $(command -v solana-sys-tuner) --user $(whoami) > sys-tuner.log 2>&1 &            

https://docs.solana.com/running-validator/validator-start#system-tuning

The test-ledger folder is done and a sys-tuner.log file is created but it's 0 bytes...

enter image description here

Then i run the solana-test-validator in a separate terminal and the other solana config commands in another termianl then i get the following results ->

Results of trying to get solana-test-validator to run

You can deploy on-chain programs with the Solana tools. To deploy a program, you will need the location of the program's shared object. It will return when you run anchor build in the command line. Run solana program deploy <PROGRAM_FILEPATH>. Successful deployment will return the program id of your program.

Related