<
 
 
 
 
×
>
hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 01:23:51 Jun 24, 2021 , and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

Can't connect to RPC on php server

Hello guys.
I am using php to connect RPC server. In localhost, everything works fine. I moved my files to host to test and I realised that $geth->Method_Name() is not working.

If I print_r($geth), here is the result.

GethApi Object ( [_options:protected] => Array ( [version] => 2.0 [host] => 165.227.103.219 [port] => 8545 [assoc] => 1 ) [_address:protected] => http://165.227.103.219:8545 [_id:protected] => 0 )


But if I wanna get block number with $geth->eth_blockNumber() here is the result in localhost:

4495121


But in php server:
Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to connect to 165.227.103.219 port 8545: Connection refused' in /home/crypuekb/public_html/GethApi.php:86


Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to connect to 165.227.103.219 port 8545: Connection refused' in /home/crypuekb/public_html/GethApi.php:86

| #0 /home/crypuekb/public_html/GethApi.php(152): GethApi->;__call('eth_blockNumber', Array)
| #1 /home/crypuekb/public_html/geth.php(14): GethApi->eth_blockNumber()
| #2 /home/crypuekb/public_html/php/db.php(7): require_once('/home/crypuekb/...')
| #3 /home/crypuekb/public_html/register.php(4): include('/home/crypuekb/...')
| #4 {main}
| thrown in /home/crypuekb/public_html/GethApi.php on line 86


Here is the line 86:
throw new \RuntimeException(curl_error($curl), curl_errno($curl));
am using this command to start geth server:
geth --rpcapi "web3,eth,personal"  --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --light
As I said, everything works perfect on localhost.. Also my php server and ethereum server is based on different hosts. And I tried my php codes at three different hosts.

I need your helps.

Regards.
Sign In or Register to comment.