CURL works only as root

0

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?

khadafi

Posted 2010-08-03T17:20:21.797

Reputation: 123

1What about wget? Just curious. – crazysim – 2010-08-03T18:14:02.243

wget, that worked! – khadafi – 2010-08-03T19:11:49.490

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 'SO- stop being evil' – 2010-08-03T20:20:27.187

I checked it and for both user it's curl is /usr/bin/curl. – khadafi – 2010-08-03T20:25:48.557

Do you have SELinux or AppArmor active? – Gilles 'SO- stop being evil' – 2010-08-03T20:54:34.510

Answers

1

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

whitequark

Posted 2010-08-03T17:20:21.797

Reputation: 14 146

Also the contents of /etc/host.conf and /etc/gai.conf (at least if there are non-comment lines). – Gilles 'SO- stop being evil' – 2010-08-03T21:00:49.070

@Gilles: thanks, added them. just never seen these files anywhere, so they missed my eye... – whitequark – 2010-08-03T21:14:39.823

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 – 2010-08-03T21:16:38.653

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 'SO- stop being evil' – 2010-08-03T21:20:46.733

1

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.

Gilles 'SO- stop being evil'

Posted 2010-08-03T17:20:21.797

Reputation: 58 319

the environment variable isn't set for both user and a .curlrc file also doesn't seems to be the solution. – khadafi – 2010-08-03T19:15:04.070

1

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.

We Are All Monica

Posted 2010-08-03T17:20:21.797

Reputation: 303

The re-installation didn't helped. But here is the output of strace curl http://www.google.com http://pastebin.com/bmFeK6Xn

– khadafi – 2010-08-03T20:35:18.023