6

This question shows research effort; it is useful and clear

I have checked the cURL not working properly

When I run the command curl -I https://www.example.com/sitemap.xml

curl: (7) Failed to connect

Failed to connect on all port

this error only on one domain, all other domain working fine, curl: (7) Failed to connect to port 80, and 443

Thanks...

Mitra
  • 362
  • 1
  • 2
  • 11

6 Answers6

16

First Check your /etc/hosts file entries, may be the URL which You're requesting, is pointing to your localhost.

If the URL is not listed in your /etc/hosts file, then try to execute following command to understand the flow of Curl Execution for the particular URL:

curl --ipv4 -v "https://example.com/";
Jaideep Ghosh
  • 634
  • 8
  • 11
9

After many search, I found that Hosts settings not correct

Then I check nano /etc/hosts The Domain point to wrong IP in hosts file

I change the wrong IP and its working Fine

This is new error Related to curl: (7) Failed to connect

Mitra
  • 362
  • 1
  • 2
  • 11
  • 1
    how to edit the host. my host shows 127.0.0.1 localhost and 127.0.0.1 example-virtual-machine. I dint use server block. I configure conf.d/default.conf to be my default proxy server and nothing else – Nick Feb 03 '19 at 10:05
  • can you upload what did you do in this file? – Rose Riyadh Jun 01 '22 at 10:55
5
curl: (7) Failed to connect

The above error message means that your web-server (at least the one specified with curl) is not running at all — no web-server is running on the specified port and the specified (or implied) port. (So, XML doesn't have anything to do with that.)

cnst
  • 25,870
  • 6
  • 90
  • 122
  • Hi, Thanks for answer, but this error only on one domain, all other domain working fine, `curl: (7) Failed to connect to port 80, and 443` – Mitra Aug 08 '17 at 21:43
  • @Mitra So, then what's your question, again?! – cnst Aug 08 '17 at 21:47
0

you can download the key with browser then open terminal in downloads then type sudo apt-key add <key_name>.asc

0

Mine is Red Hat Enterprise(RHEL) Virtual Machine and I was getting something like the following.

Error "curl: (7) Failed to connect to localhost port 80: Connection refused"

I stopped the firewall by running the following commands and it started working.

sudo systemctl stop firewalld
sudo systemctl disable firewalld
VivekDev
  • 20,868
  • 27
  • 132
  • 202
0

If the curl is to the outside world, like:

curl www.google.com

I have to restart my cntlm service:

systemctl restart cntlm

If it's within my network:

curl inside.server.local

Then a docker network is overlapping something with my CNTLM proxy, and I just remove all docker networks to fix it - you can also just remove the last network you just created, but I'm lazy.

docker network rm $(docker network ls -q)

And then I can work again.

D at T
  • 3
  • 2