LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   curl: (7) couldn't connect to host // wget --> failed: Connection refused. (https://www.linuxquestions.org/questions/linux-newbie-8/curl-7-couldnt-connect-to-host-wget-failed-connection-refused-728866/)

linea 05-27-2009 10:35 AM

curl: (7) couldn't connect to host // wget --> failed: Connection refused.
 
Hi all,

I am quite a newbie. I have Mandriva 2009 Spring installed on a Thinkpad T40. All works well but since last week I have broken somehow curl and wget :

Quote:

[tompot@localhost]$ wget http://www.yahoo.com
--2009-05-28 08:08:58-- http://www.yahoo.com/
Connecting to 217.19.195.242:80... failed: Connection refused.
Quote:

[tompot@localhost]$ curl http://www.yahoo.com
curl: (7) couldn't connect to host
One clue I have is, since I installed XAMPP, I have created the xampp service and might have modified something else for curl and wget.

Please, don't hesitate to refer me to another solved thread to reseach.

Thank you

Tinkster 05-27-2009 11:36 AM

Hi

welcome to LQ!

Is the URL still accessible via ordinary browser? What's the
network topology, are you behind a proxy/firewall? What do
you see when you
Code:

telnet www.yahoo.com 80
?


Cheers,
Tink

linea 05-27-2009 12:32 PM

Thanks Tinkster,

I forgot to mention
  • I have still perfect access to the internet (all url) via http and ftp with FF 3.0.10.
  • lynx doesn't seem to be working :
    Quote:

    [tompot@localhost]$ lynx http://www.yahoo.com

    Looking up 217.19.195.242
    Making HTTP connection to 217.19.195.242
    Alert!: Unable to connect to remote host.

    lynx: Can't access startfile http://www.yahoo.com/
  • Telnet isn't installed on my config.
  • but dig seems to work :
    Quote:

    dig www.yahoo.com

    ; <<>> DiG 9.6.0-P1 <<>> www.yahoo.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35081
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

    ;; QUESTION SECTION:
    ;www.yahoo.com. IN A

    ;; ANSWER SECTION:
    www.yahoo.com. 241 IN CNAME www.wa1.b.yahoo.com.
    www.wa1.b.yahoo.com. 4 IN CNAME www-real.wa1.b.yahoo.com.
    www-real.wa1.b.yahoo.com. 23 IN A 209.131.36.158

    ;; Query time: 21 msec
    ;; SERVER: 68.87.69.146#53(68.87.69.146)
    ;; WHEN: Thu May 28 10:23:56 2009
    ;; MSG SIZE rcvd: 94
  • Network is local wifi with 3 machines + printer. Sisco router.


Where should I start looking ?

linea 05-27-2009 01:01 PM

I tried Konqueror. Same probleme as Lynx not access to any url.

Either somehting special with my firefox config for http and the filezilla for ftp.
Or Firefox is messing up the mandriva build-in browsers.

Tinkster 05-27-2009 02:02 PM

I don't think ff has that power ... if you don't have telnet - how about netcat?
Is SE Linux enabled, and your FF the only browser permitted out on ports 80
and/or 443?

You could also try to run curl or wget under strace, log info ot a file and
see where you get errors/permission problems ...


Cheers,
Tink

linea 05-27-2009 03:34 PM

Quote:

I don't think ff has that power ... if you don't have telnet - how about netcat?
Is SE Linux enabled, and your FF the only browser permitted out on ports 80
and/or 443?

You could also try to run curl or wget under strace, log info ot a file and
see where you get errors/permission problems ...
No telnet, no netcat either
SELinux is RH distro isn't it ? I am Mandriva.--> no idea about ports opened for which browser.

I am looking at the strace output... won't be easy

For info while I try to understand the raw output, here is the -c output :
Quote:

strace -c wget www.yahoo.com
--2009-05-28 13:31:34-- http://www.yahoo.com/
Connecting to 217.19.195.242:80... failed: Connection refused.
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
81.97 0.001000 1000 1 1 connect
15.74 0.000192 192 1 execve
2.30 0.000028 1 25 fstat64
0.00 0.000000 0 13 read
0.00 0.000000 0 3 write
0.00 0.000000 0 37 13 open
0.00 0.000000 0 27 close
0.00 0.000000 0 3 time
0.00 0.000000 0 1 1 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 2 ioctl
0.00 0.000000 0 4 munmap
0.00 0.000000 0 1 uname
0.00 0.000000 0 5 mprotect
0.00 0.000000 0 1 _llseek
0.00 0.000000 0 7 rt_sigaction
0.00 0.000000 0 1 rt_sigprocmask
0.00 0.000000 0 1 getrlimit
0.00 0.000000 0 35 mmap2
0.00 0.000000 0 6 4 stat64
0.00 0.000000 0 2 futex
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 2 socket
0.00 0.000000 0 1 bind
0.00 0.000000 0 1 getsockname
0.00 0.000000 0 1 sendto
0.00 0.000000 0 3 recvmsg
------ ----------- ----------- --------- --------- ----------------
100.00 0.001220 190 19 total
Quote:

strace -c curl www.yahoo.com
curl: (7) couldn't connect to host
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
64.90 0.007394 130 57 read
26.33 0.003000 45 66 21 open
8.77 0.000999 999 1 execve
0.00 0.000000 0 35 write
0.00 0.000000 0 47 close
0.00 0.000000 0 5 time
0.00 0.000000 0 4 2 access
0.00 0.000000 0 1 pipe
0.00 0.000000 0 2 times
0.00 0.000000 0 4 brk
0.00 0.000000 0 2 1 ioctl
0.00 0.000000 0 2 getrusage
0.00 0.000000 0 2 gettimeofday
0.00 0.000000 0 6 munmap
0.00 0.000000 0 1 uname
0.00 0.000000 0 19 mprotect
0.00 0.000000 0 25 select
0.00 0.000000 0 1 poll
0.00 0.000000 0 2 rt_sigaction
0.00 0.000000 0 1 rt_sigprocmask
0.00 0.000000 0 1 getrlimit
0.00 0.000000 0 78 mmap2
0.00 0.000000 0 7 6 stat64
0.00 0.000000 0 44 fstat64
0.00 0.000000 0 4 fcntl64
0.00 0.000000 0 2 futex
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 12 clock_gettime
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 1 socket
0.00 0.000000 0 1 1 connect
0.00 0.000000 0 1 setsockopt
0.00 0.000000 0 1 getsockopt
------ ----------- ----------- --------- --------- ----------------
100.00 0.011393 438 31 total

linea 06-01-2009 11:28 AM

My search didn't bring me anywhere :(

Can someone help me ?

Tinkster 06-01-2009 11:45 AM

Not with that amount of info. I'd highly recommend installing
either telnet or nc (nc being the predfered choice because it's
far more versatile).


Cheers,
Tink

jamescondron 06-01-2009 11:50 AM

Whats in /etc/hosts? Firefox used to do funny things resolving via hosts, especially if you have some proxy set up. Is that all clear?

linea 06-02-2009 01:06 AM

Thank you.

Quote:

Originally Posted by jamescondron (Post 3559223)
Whats in /etc/hosts? Firefox used to do funny things resolving via hosts, especially if you have some proxy set up. Is that all clear?

Give me :
Quote:

[root@localhost etc]# more hosts
127.0.0.1 localhost

Quote:

Not with that amount of info. I'd highly recommend installing
either telnet or nc (nc being the predfered choice because it's
far more versatile).


Cheers,
Tink
I managed to install netcat. Here is what it gives :
Quote:

[root@localhost etc]# netcat -v www.yahoo.com 80
www.yahoo.com [209.131.36.158] 80 (http) open
read(net): Connection reset by peer

Tinkster 06-02-2009 01:32 AM

Hummm ... still doesn't make any sense. Is there a proxy
somewhere that firefox knows about, and other browsers
don't?

linea 06-02-2009 01:38 PM

Excellent Tink, you got me on the way.
I feel like a moron now.:o :redface:

I changed proxy settings on drake gui...
Now wget and curl is working.

However netcat is still giving me the same thing.

In my mother tongue I'd say "Touche pas à ca p'tit con".

Thanks a lot Tink.

Mcdo 05-21-2012 12:56 PM

Did you use a proxy?
 
curl and wget try to download things through proxy even if the proxy is unavailable. so the simplest way is to export http_proxy="" and put it into your .bash_profile.


All times are GMT -5. The time now is 08:35 PM.