<p>Very likely you need to tell your PHP JSON RPC client to connect to the right port.</p>

<p>If you start bitcoind <strong>without</strong> <code>-regtest</code> (= main net), it opens up the RPC server on port <code>8332</code>.
If you use <code>-regtest</code>, the port will be <code>18332</code>.</p>

<p>I can't see what kind of PHP JSON RPC client you are using, but there must be a way to tell it should use port 18332.</p>

CC BY-SA 3.0
2018-04-26T06:17:02.907Z
so this answer works? so you mean we should write this line at bitcoin.conf file?

rpcport=18332
creator
CC BY-SA 3.0
2015-08-13T07:13:29.433Z
2015-08-13T11:44:45.520Z
2015-08-13T11:44:45.520Z
Jonas Schnelli
<p>i used bitcoind with jsonrpc service. </p>

<p>but i added <code>regtest=1</code> in <code>bitcoin.conf</code> at <code>.bitcoin</code> folder.</p>

<p>used:</p>

<blockquote>
  <p>bitcoin-cli -regtest generate 101</p>
  
  <p>bitcoin-cli -regtest getbalance</p>
  
  <p>50.00000000</p>
</blockquote>

<p>but I can't see the balance in php.</p>

<blockquote>
  <p>$bitcoin->getbalance()</p>
</blockquote>

<p>it doesn't show me the balance. it returns nothing.</p>

<p>if I remove <code>regtest=1</code> from <code>bitcoin.conf</code> and start <code>bitcoind -daemon</code>.</p>

<blockquote>
  <p>$bitcoin->getbalance()
  it gives me the the real server balance.</p>
</blockquote>

<p>what is solution for this problem??? </p>

CC BY-SA 3.0
2015-08-13T06:39:37.837Z
This might be a stupid question, but are you echoing the return value of `$bitcoin->getbalance()` ? Also, what error logging level do you have set?
Nick ODell
CC BY-SA 3.0
2015-08-13T06:50:13.200Z
I think you are the stupid one commented on this question. if i can see the error then I will definitely add in body. don't ignore those people who need to learn something. if you have power of knowledge  then use this. if you don't understand my question then you can comment.
Md Shahadat Hossain
CC BY-SA 3.0
2015-08-13T06:59:41.767Z
I wasn't trying to insult you or your question. In this context, "This might be a stupid question" means that I'm about to ask you about a debugging step that I think you've probably done, but I don't know for sure.
Nick ODell
<bitcoind><bitcoin-core><testnet><regtest>
how to use bitcoind jsonrpc for regtest or testnet server in php?
Md Shahadat Hossain
# how to use bitcoind jsonrpc for regtest or testnet server in php?

(Asked by: username_0 on 2015-08-13)

i used bitcoind with jsonrpc service.

but i added `regtest=1` in `bitcoin.conf` at `.bitcoin` folder.

used:

> bitcoin-cli -regtest generate 101
>
> bitcoin-cli -regtest getbalance
>
> 50.00000000

but I can't see the balance in php.

> $bitcoin->getbalance()

it doesn't show me the balance. it returns nothing.

if I remove `regtest=1` from `bitcoin.conf` and start `bitcoind -daemon`.

> $bitcoin->getbalance()
> it gives me the the real server balance.

what is solution for this problem???

**Tags:** bitcoind, bitcoin-core, testnet, regtest

> **Comments:**
> **username_1**: This might be a stupid question, but are you echoing the return value of `$bitcoin->getbalance()` ? Also, what error logging level do you have set?  
> **username_0**: I think you are the stupid one commented on this question. if i can see the error then I will definitely add in body. don't ignore those people who need to learn something. if you have power of knowledge  then use this. if you don't understand my question then you can comment.  
> **username_1**: I wasn't trying to insult you or your question. In this context, "This might be a stupid question" means that I'm about to ask you about a debugging step that I think you've probably done, but I don't know for sure.  

---

## 1 answers

### Answer by username_2 on 2015-08-13. Score: 3

Very likely you need to tell your PHP JSON RPC client to connect to the right port.

If you start bitcoind **without** `-regtest` (= main net), it opens up the RPC server on port `8332`.
If you use `-regtest`, the port will be `18332`.

I can't see what kind of PHP JSON RPC client you are using, but there must be a way to tell it should use port 18332.

> **Comments:**
> **username_3**: so this answer works? so you mean we should write this line at bitcoin.conf file?  rpcport=18332  

---

