Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can not deploy the program to dev net with anchor

I get this error where I run anchor deploy:

Deploying workspace: http://127.0.0.1:8899
Upgrade authority: /home/<user>/.config/solana/id.json
Deploying program "faucet"...
Program path: /home/<user>/Workspace/<project_path>/target/deploy/xxx.so...
Error: RPC request error: cluster version query failed: error sending request for url (http://127.0.0.1:8899/): error trying to connect: tcp connect error: Connection refused (os error 111)
There was a problem deploying: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "" }.

Before deploying, I have already run the following to change the cluster config in local:

solana config set --url https://api.devnet.solana.com

How can I solve the problem?

like image 675
Noldorin Zhang Avatar asked Dec 23 '22 15:12

Noldorin Zhang


2 Answers

Your error clearly states that while you are trying to deploy to your local network, it is not up and running. So, what you have to do is simply open a new terminal window and run:

solana-keygen new

save the seed phrase and other relevant details somewhere secure and then, run

solana-test-validator

Now in a separate terminal window where you had earlier tried to deploy, type

anchor deploy 

again and it should be successfully deployed.

Else, if you were trying to deploy on any other network, for example, devnet. Then you would want to airdrop some SOL into the account generated after running solana-keygen new using the command:

solana airdrop 1 <RECIPIENT_ACCOUNT_ADDRESS> --url https://api.devnet.solana.com

Then use additional flags in your deploy command as follows:

anchor deploy --provider.cluster devnet
like image 71
Rahul Saxena Avatar answered Dec 27 '22 06:12

Rahul Saxena


Your error suggests that you are actually trying to deploy to local but your local is down. When deploying to clusters other than local, you need to add

anchor deploy --provider.cluster devnet

you can get more help from

anchor --help
like image 39
yangli-io Avatar answered Dec 27 '22 06:12

yangli-io