The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php Error opening socket

Discussion in 'General Discussion' started by Markwaugh, Dec 13, 2003.

  1. Markwaugh

    Markwaugh Well-Known Member

    Joined:
    Aug 12, 2003
    Messages:
    151
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Sydney, Australia
    Hello,

    php can no longer open a socket from my site.

    Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/chris/public_html/test.php on line 10

    Warning: fsockopen(): unable to connect to weather.noaa.gov:80 in /home/chris/public_html/test.php on line 10
    fp=0,errno=13, errstr=Permission denied

    This same program has been working without error for several months. now it is not working. any ideas would be higly appreciated.
     
  2. jamesbond

    jamesbond Well-Known Member

    Joined:
    Oct 9, 2002
    Messages:
    738
    Likes Received:
    1
    Trophy Points:
    18
    Perhaps you have safe_mode enabled?

    (disabling safe_mode for that account will probably solve your Image Magick problem as well)
     
  3. Markwaugh

    Markwaugh Well-Known Member

    Joined:
    Aug 12, 2003
    Messages:
    151
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Sydney, Australia
    hmmm, well I tried safe mode both enabled and disabled, no luck .... i edited .htaccess file for correcting warning message and still the other error remains. there is no warning message now. I tried executing the script http://in.php.net/manual/en/function.fsockopen.php it says no such file or directory except the 3rd example.

    1st example and 2nd example does not work for me ...

    any thoughts would be highly appreciated ???? :(
     
    #3 Markwaugh, Dec 13, 2003
    Last edited: Dec 13, 2003
  4. anton_latvia

    anton_latvia Well-Known Member
    PartnerNOC

    Joined:
    May 11, 2004
    Messages:
    348
    Likes Received:
    3
    Trophy Points:
    18
    Location:
    Latvia
    cPanel Access Level:
    Root Administrator
    Hi,
    did you solve your problem with fsockopen()?

    Anton.
     
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    It would help if you stuck to one thread when asking the same question.
     
  6. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    I've searched google, WHT and this forum, and this post is the closest I've seen to my problem, but I'm finding no solution.

    A client's script has stopped working. It is a PPC search engine with country filters, and has to pull feed results from other servers.

    Here is what the error looks like:
    The client's programmer insists it is not a problem in the script, but a problem with fsockopen() on the server.

    At first the programmer said fsockopen() was not enabled, but I put in a ticket with my server providers and they said it's open.

    I looked at the default settings in WHM in Main >> Software >> Apache Update and Sockets is checked by default, so unless something has changed since the last time I rebuilt apache that would have been checked back then. But it's been a long while since I rebuilt apache so nothing should have changed lately, but the client's script hasn't worked for a couple weeks.

    Can someone give me idiot instructions for troubleshooting this, please?
     
    #6 junglecat, Oct 13, 2005
    Last edited: Oct 13, 2005
  7. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    You can try with the following script to check it the fsockopen(): is working or not :

    PHP:
    <?
    $ipaddress "udp://192.168.0.1";
    $port 80;
    $test fsockopen($ipaddress,$port,&$errno,&$errstr);
    if (!
    $test) {
    echo 
    "DOWN\n";
    } else {
    echo 
    "UP\n";
    }
    ?>
    If you get DOWN then it is not working and if you get UP then it is working fine.

    The error which you get is normally when the port is blocked or domain or IP address is not reachable..
     
  8. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Very cool little script, thanks. :)

    It shows UP.

    But the error is definitely not due to an IP that's down, I ran the file from the client's script in my browser using various IP's and all showed the same error.
     
  9. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    Do you have Firewall installed on your server ??
     
  10. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Yes I do. I even thought of the firewall maybe blocking something, but I don't know how to check.
     
  11. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    Just disable(stop) the Firewall and try if it works..
     
  12. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Hmm, ok, I tried service firewall stop and service apf stop and both times got unrecognized service. Is there another way to do that?
     
  13. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    I am sorry there some altrationin the script I provided you earlier, this is the correct one :

    PHP:
    <?
    $ipaddress "tcp://IP_address";   
    $port 80;
    $test fsockopen($ipaddress,$port,&$errno,&$errstr);
    if (!
    $test) {
    echo 
    "DOWN\n";
    } else {
    echo 
    "UP\n";
    }
    ?>
    replace udp with tcp... as UDP will always show up.. coz that is how UDP works :p
     
  14. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16

    Ok, did that, and guess what, it shows DOWN :rolleyes: So how do I enable it? Would that be in php.ini and if so, appx what line? It's big and scary in php.ini lol I get lost in there.

    PS if UDP always shows Up what's the point? :p
     
  15. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    Does it show down for all the IPs or did you try replacing the IP with google.com or yahoo.com.. Also have you tried disabling your Firewall..

    Well I am sure it is not a cpanel issue.. it is either your network or firewall that is not allowing to open socket.
     
  16. junglecat

    junglecat Well-Known Member

    Joined:
    Jul 6, 2004
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Ok, IP's, google.com and yahoo.com all show it to be down.

    How does one stop the firewall, service firewall stop and service apf stop both get unrecognized service.

    Sorry for posting in cpanel folder, I would have posted in general except I bumped a topic I found by searching.
     
  17. Murtaza_t

    Murtaza_t Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    476
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Earth
    cPanel Access Level:
    Website Owner
    To disable Firewall run :

    ]# service iptables stop

    If you still face the same problems then try running
    ]# /scripts/makecpphp -- still the same problem try
    ]# /scripts/upcp

    I think I will take a brake now... But I wish you best luck on this.. :)
     
Loading...

Share This Page