Bitcoin Forum
April 18, 2024, 08:58:37 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can’t connect to bitcoind from web server  (Read 3042 times)
BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 15, 2017, 01:38:53 PM
Merited by ABCbits (1)
 #1

Hello to everybody!
I have a bitcoind daemon running on a VPS server (ocean digital). Everything is set up ok and it is running with no issues!


I put this script in /var/www/html/test_call.php (in same folder with easybitoin.php) in the VPS (ocean digital):
Code:
<?php
require('easybitcoin.php');
$bitcoin = new Bitcoin('ausername''apassword''localhost');
$info $bitcoin->getinfo(); 
print_r($info); 
?>


and everything is OK as I receive something like : Array ( [version] => 140000 [protocolversion] =>



Now, my problem is when I put the script in the Godaddy Web server /public_html/test_call.php (in same folder with easybitoin.php) it gives me a blanc screen. I do that because I don't want my web site run in the same server with the VPS that runs bitcoind (i will add later a SSH tunnel between them). Here is the test_call.php file in GoDaddy:
Code:
<?php
require('easybitcoin.php');
$bitcoin = new Bitcoin('ausername''apassword''IP of VPS Ocean Digital');
$info $bitcoin->getinfo(); 
print_r($info); 
?>



And here is the bitcoin.conf:
Code:
rpcuser=ausername
rpcpassword=apassword
daemon=1
server=1
rpcallowip=the Website IP for GoDaddy
keypool=10000
prune=600
maxuploadtarget=20
maxconnections=16


I also tried opening ports 8332 and 8333 in the VPS (ocean digital) with
Code:
sudo ufw allow
with no result.


I also changed the port in bitcoin config by adding the line
Code:
rpcport=570
and by changing line 3 in test_call.php
Code:
$bitcoin = new Bitcoin('ausername', 'apassword', 'IP of VPS Ocean Digital', '570');



I searched a lot and found a lot of similar issues from other users, but I couldn’t find the solution.
It seems like am doing something wrong and the rpc is not working properly.
Any ideas please?

Thank you
Nick
1713430717
Hero Member
*
Offline Offline

Posts: 1713430717

View Profile Personal Message (Offline)

Ignore
1713430717
Reply with quote  #2

1713430717
Report to moderator
1713430717
Hero Member
*
Offline Offline

Posts: 1713430717

View Profile Personal Message (Offline)

Ignore
1713430717
Reply with quote  #2

1713430717
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713430717
Hero Member
*
Offline Offline

Posts: 1713430717

View Profile Personal Message (Offline)

Ignore
1713430717
Reply with quote  #2

1713430717
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3360
Merit: 6505


Just writing some code


View Profile WWW
April 15, 2017, 04:05:01 PM
 #2

Make sure that digital ocean itself is letting you receive traffic to port 8332. I know that with AWS that you need to configure some security settings of the VPS itself outside of its OS to allow traffic to certain ports.

BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 15, 2017, 04:18:48 PM
 #3

Thank you for your reply, I thought that port 8333 was ok because the server runs ok and received all the blocks.
I just created a ticked asking them if they block that port by default (and what to do to fix that)...

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3360
Merit: 6505


Just writing some code


View Profile WWW
April 15, 2017, 04:23:25 PM
Merited by ABCbits (1)
 #4

Thank you for your reply, I thought that port 8333 was ok because the server runs ok and received all the blocks.
I just created a ticked asking them if they block that port by default (and what to do to fix that)...
Receiving blocks and transactions does not mean that port 8333 is open. Bitcoin Core will make outbound connections (which are usually allowed by default) to other nodes in order to connect to the network. You won't have any incoming connections if you don't open port 8333.

BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 17, 2017, 06:12:48 PM
 #5

I contacted Ocean Digital who proposed me to open needed ports with:
Code:
sudo ufw allow port [port number]

I dit it and then with:
Code:
Sudo ufw status verbose
  I saw that all needed ports (8332 and 8333) are opened!!

Then I went here : http://www.yougetsignal.com/tools/open-ports/ to check the ports. I saw that port 8333 was open, but port 8332 remained closed!!
 
So I opened another port (2424) with
Code:
sudo ufw allow 2424
something that was proved successful here:  http://www.yougetsignal.com/tools/open-ports/.


When I run /var/www/html/test_call.php from the VPS (Ocean Digital)
Code:
<?php
require('easybitcoin.php');
$bitcoin = new Bitcoin('ausername''apassword''localhost''2424');
$info $bitcoin->getinfo(); 
print_r($info); 
echo 
$info $info "Oops an error: ".$bitcoin->error;
?>

everything is ok because I receive: Array [version] => 140000 [protocolversion] => ...


BUT when I try to put the script in the Godaddy Web server
Code:
<?php
require('easybitcoin.php');
$bitcoin = new Bitcoin('ausername''apassword''IP of VPS Ocean Digital''2424');
$info $bitcoin->getinfo(); 
print_r($info); 
echo 
$info $info "Oops an error: ".$bitcoin->error;
?>

then I keep receiving: Oops an error: Failed to connect to [IP-VPS] port 2424: Connection refused


Here is the actual bitcoin.conf file which is placed in /root/.bitcoin/bitcoin.conf in the VPS Server (Ocean Digital) running bitcoind.
Code:
rpcuser=ausername
rpcpassword=apassword
daemon=1
server=1
rpcport=2424
rpcallowip=the Website IP for GoDaddy
keypool=10000
prune=600
maxuploadtarget=20
maxconnections=16



I tried everything, I searched for about a week a solution for this issue but I nothing helped me. I checked tenths of pages who proposed different things  (adding rpcbind=<addr>rpcconnect=<addr>, even adding bitcoin.conf on both VPS and web server!! here https://bitcoin.stackexchange.com/questions/43216/connection-refused-from-external-server).
I am completely lost!

I am VERY tired, so I decided to offer 50$ in bitcoins to the person who really helps me with that!

I would appreciate if you could help me resolving this issue.


Thank you,

Nick
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3360
Merit: 6505


Just writing some code


View Profile WWW
April 17, 2017, 07:16:08 PM
 #6

Make sure that your godaddy server allows outgoing connections to whatever rpcport you are using.

BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 17, 2017, 08:27:17 PM
 #7

The server has cPanel... is it possible to check it there?
(as I remember I don't have root access)
BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 18, 2017, 08:30:18 AM
 #8

I contacted GoDaddy. It is not possible to manually open ports as I don't have root access there.
But, I checked with an online port scanner and I saw that there are open ports. I used them with no success...
cloverme
Legendary
*
Offline Offline

Activity: 1512
Merit: 1054


SpacePirate.io


View Profile WWW
April 18, 2017, 12:00:57 PM
Merited by ABCbits (2)
 #9

So, a couple of things to try... Your server is going to have 2 ip addresses, the ip address that's internal to the server and one that is a public ip address.

In your bitcoin.conf file, for rpcallowip, use the internal ip address, which is where the requests are coming from. It's likely that the firewall is blocking the local port on the local ip address. I'm not sure what kind of shell access you have on your host, but you could temporarily stop the firewall service to see if you get a connect to see if the issue is isolated to your firewall, just remember to turn it back on Wink

https://www.godaddy.com/help/configuring-firewall-ip-addresses-in-simple-control-panel-2297
https://www.godaddy.com/help/find-your-servers-ip-address-12071

If you change the ip address in the the .conf file, you have to remember to restart bitcoind to pick up the new settings. If you're tired, you might miss a restart in troubleshooting.


What kind of Godaddy hosting service are you using? I might have some credits where I can use them and give you step by step instructions for setup and configuration.



BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 19, 2017, 07:47:05 PM
Last edit: April 19, 2017, 08:21:20 PM by BitcoinPot
 #10

The links that you are giving me do not refer to the type of Godaddy. It is not a dedicated server, it's just web hosting. Precisely it is "Deluxe Linux Hosting with cPanel" so I have access to it via cPanel. From what I saw I can only ban IPs, but not open ports.
I can access also via SSH (with PuTTY) and FTP, but I do not have root access...

I already did in bitcoin.config as you say...
Code:
rpcuser=ausername
rpcpassword=apassword
daemon=1
server=1
rpcport=2424
rpcallowip=the Website IP for GoDaddy
keypool=10000
prune=600
maxuploadtarget=20
maxconnections=16


The thing does not work remotely and I don't know if I am missing something...  Huh

jonald_fyookball
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
April 20, 2017, 02:02:36 AM
 #11

The links that you are giving me do not refer to the type of Godaddy. It is not a dedicated server, it's just web hosting. Precisely it is "Deluxe Linux Hosting with cPanel" so I have access to it via cPanel. From what I saw I can only ban IPs, but not open ports.
I can access also via SSH (with PuTTY) and FTP, but I do not have root access...

I already did in bitcoin.config as you say...
Code:
rpcuser=ausername
rpcpassword=apassword
daemon=1
server=1
rpcport=2424
rpcallowip=the Website IP for GoDaddy
keypool=10000
prune=600
maxuploadtarget=20
maxconnections=16


The thing does not work remotely and I don't know if I am missing something...  Huh




if its not your dedicated server and you dont have root, you will have to ask your host to do the commands for you. they may or may not allow it depending on their policies. 

cloverme
Legendary
*
Offline Offline

Activity: 1512
Merit: 1054


SpacePirate.io


View Profile WWW
April 21, 2017, 04:22:18 PM
 #12

While not on your exact topic of help... Why did you move hosts to godaddy if it was working at ocean digital?  Ocean has some of the best documentation for lamp stacks and securing them. Godaddy is not really that great at a lot of services, in the end, you'll get frustrated and want to move away from them.
BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 21, 2017, 06:19:28 PM
 #13

You are right. I think I will leave Godaddy, especially if it is a port problem and refuse to open it... I already lost 2 weeks with this issue.
Do they refund the remaining period if I stop with them?
cloverme
Legendary
*
Offline Offline

Activity: 1512
Merit: 1054


SpacePirate.io


View Profile WWW
April 24, 2017, 01:02:51 PM
 #14

You can try, but they're kind of dickheads about payments and orders when they became the walmart of domain/hosting. My guess is that if you don't take no for an answer, you might be able to get a refund. Good luck  Wink
BitcoinPot (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 2


View Profile
April 28, 2017, 08:03:35 PM
Last edit: April 28, 2017, 10:30:35 PM by BitcoinPot
 #15

I got a total refund from Godaddy (they were very professional) and bought a second VPS server from DigitalOcean. I connected the two servers and the thing works like a charm! The issue was resolved!
It was clearly a "Goddady issue".

I think that Achow101 gave the exact answer to the problem:

Make sure that your godaddy server allows outgoing connections to whatever rpcport you are using.
 
But Cloverme helped me a lot too with his posts!  

Achow101 please give me your address (pm), I will send you 45$ in BTC.
Cloverme please give me your address (pm), I will send you 15$ in BTC.
60$ total in BTC (instead of 50)

I hope you agree. Smiley

ps: jonald_fyookball thank you too man for your time! Wink



Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!