Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm on an Ubuntu 10.04 installation and somehow curl stopped working with my user. I always receive: curl: (7) couldn't connect to host. It only works as root. Can anyone help me?

share|improve this question
1  
What about wget? Just curious. –  crazysim Aug 3 '10 at 18:14
    
wget, that worked! –  khadafi Aug 3 '10 at 19:11
    
Is curl an alias of shell function for one of the user, or do you have more than one version installed with the users reaching different versions because of different PATH settings (what does type curl say)? –  Gilles Aug 3 '10 at 20:20
    
I checked it and for both user it's curl is /usr/bin/curl. –  khadafi Aug 3 '10 at 20:25
    
Do you have SELinux or AppArmor active? –  Gilles Aug 3 '10 at 20:54
add comment

3 Answers

up vote 0 down vote accepted

I checked the curl google.comstrace log and the key line is surely 409:

connect(3, {sa_family=AF_INET, sin_port=htons(9999), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)

If I (for the testing) launch curl http://localhost:1357, I get in the strace:

connect(3, {sa_family=AF_INET, sin_port=htons(1357), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)

So, by some weird reason instead of google.com curl tries to connect to localhost:9999.

Can you post:

  • /etc/hosts
  • /etc/nsswitch.conf
  • ~/.bashrc
  • /etc/host.conf
  • /etc/gai.conf
  • output of ldd /usr/bin/curl
  • output of env
share|improve this answer
    
Also the contents of /etc/host.conf and /etc/gai.conf (at least if there are non-comment lines). –  Gilles Aug 3 '10 at 21:00
    
@Gilles: thanks, added them. just never seen these files anywhere, so they missed my eye... –  whitequark Aug 3 '10 at 21:14
    
Thanks for your hint with the output of env! A network proxy were enabled. The ALL_PROXY and all_proxy were set. Finally after disabling the proxy everything works. –  khadafi Aug 3 '10 at 21:16
    
I'd never seen them either, but the # Configuration for getaddrinfo at the top of /etc/gai.conf caught my eye. And line 409 is a replay of 386, which presumably follows a getaddrinfo call. –  Gilles Aug 3 '10 at 21:20
add comment

I am thinking that maybe some library that curl needs is now only accessible by root for whatever reason. A couple of things you could try:

sudo apt-get purge curl libcurl3
sudo apt-get install curl

then, if that doesn't fix it:

strace curl http://site.com/file.txt &> curl.log

and post the output on pastebin.com or something for us.

share|improve this answer
    
The re-installation didn't helped. But here is the output of strace curl google.com pastebin.com/bmFeK6Xn –  khadafi Aug 3 '10 at 20:35
add comment

Maybe one user is using a proxy and the other one isn't. See if either your user or root has the http_proxy or HTTP_PROXY environment variable defined.

Also see if root has a .curlrc file that contains an option that makes it work, or if your user has a .curlrc that makes it not work.

share|improve this answer
    
the environment variable isn't set for both user and a .curlrc file also doesn't seems to be the solution. –  khadafi Aug 3 '10 at 19:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.