wget can't download - 404 error
Asked Answered
H

9

37

I tried to download an image using wget but got an error like the following.

--2011-10-01 16:45:42--  http://www.icerts.com/images/logo.jpg
Resolving www.icerts.com... 97.74.86.3
Connecting to www.icerts.com|97.74.86.3|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2011-10-01 16:45:43 ERROR 404: Not Found.

My browser has no problem loading the image. What's the problem? curl can't download either.

Thanks.

Sam

Hull answered 1/10, 2011 at 23:47 Comment(2)
Are you sure the image isn't cached in your browser? I get 404 when I try to grab it. If you have firebug, look to see if it's pulling the file from your disk or trying to get it from the server.Spar
When you type icerts.com/images/logo.jpg into your browser, can you see the image, (I can't) ? Maybe the specified document has not been found on the server.Hiltan
B
26

You need to add the referer field in the headers of the HTTP request. With wget, you just need the --header arg :

wget http://www.icerts.com/images/logo.jpg --header "Referer: www.icerts.com"

And the result :

--2011-10-02 02:00:18--  http://www.icerts.com/images/logo.jpg
Résolution de www.icerts.com (www.icerts.com)... 97.74.86.3
Connexion vers www.icerts.com (www.icerts.com)|97.74.86.3|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 6102 (6,0K) [image/jpeg]
Sauvegarde en : «logo.jpg»
Brassy answered 2/10, 2011 at 0:5 Comment(2)
wget mirror.sdunix.com/apache//ant/binaries/apache-ant-1.9.4-bin.zip I am trying this link , not working , i tried it with header filed too, but failedRuppert
Anyone care to elaborate on why the header is needed? (it didn't work for me anyway, but would like to be clearer)Pianette
C
15

I had the same problem with a Google Docs URL. Enclosing the URL in quotes did the trick for me:

wget "https://docs.google.com/spreadsheets/export?format=tsv&id=1sSi9f6m-zKteoXA4r4Yq-zfdmL4rjlZRt38mejpdhC23" -O sheet.tsv
Changeup answered 5/5, 2015 at 21:52 Comment(1)
Thank you! That was it for me!Alien
G
14

You will also get a 404 error if you are using ipv6 and the server only accepts ipv4.

To use ipv4, make a request adding -4:

wget -4 http://www.php.net/get/php-5.4.13.tar.gz/from/this/mirror
Garlaand answered 17/3, 2013 at 19:27 Comment(0)
T
8

I had same problem. Solved using single quotes like this:

$ wget 'http://www.icerts.com/images/logo.jpg'

wget version in use:

$ wget --version
GNU Wget 1.11.4 Red Hat modified
Technique answered 9/11, 2017 at 13:57 Comment(0)
T
0

Wget 404 error also always happens if you want to download the pages from Wordpress-website by typing

wget -r http://somewebsite.com

If this website is built using Wordpress you'll get such an error:

ERROR 404: Not Found.

There's no way to mirror Wordpress-website because the website content is stored in the database and wget is not able to grab .php files. That's why you get Wget 404 error.

I know it's not this question's case, because Sam only wants to download a single picture, but it can be helpful for others.

Tarrasa answered 6/1, 2019 at 12:55 Comment(1)
wget is not able to grab .php files content, but it capture the text generated by the php file. This is exactly the same case for a browserPieeyed
L
0

Actually I don't know what is the reason exactly, I have faced this like of problem. if you have the domain's IP address (ex 208.113.139.4), please use the IP address instead of domain (in this case www.icerts.com)

wget 192.243.111.11/images/logo.jpg

Go to find the IP from URL https://ipinfo.info/html/ip_checker.php

Leaguer answered 27/8, 2020 at 11:23 Comment(0)
M
0

I want to add something to @blotus's answer,

In case adding the referrer header does not solve the issue, May be you are using the wrong referrer (Sometimes the referrer is different from the URL's domain name).

Paste the URL on a web browser and find the referrer from developer tools (Network -> Request Headers).

Misgiving answered 25/6, 2021 at 11:26 Comment(0)
S
0

I met exactly the same problem while setting up GitHub actions with Cygwin. Only after I used wget --debug <url>, I realized that URL is appended with 0xd symbol which is \r (carriage return).

For this kind of problem there is the solution described in docs:

you can also use igncr in the SHELLOPTS environment variable

So I added the following lines to my YAML script to make wget work properly, as well as other shell commands in my GHA workflow:

env:
  SHELLOPTS: igncr 
Stranglehold answered 24/11, 2022 at 12:51 Comment(0)
D
0

For me I was trying the below command -

sudo wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.75/bin/apache-tomcat-8.5.75.tar.gz

It was giving me same error because this file was not found at the server location because only latest versions are maintained looks like.

I tried using the latest version like below it works fine.

sudo wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.gz 

Posting so that it might help someone.

Danita answered 9/10, 2023 at 5:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.