Sam Kong
Sam Kong

Reputation: 5810

wget can't download - 404 error

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

Upvotes: 38

Views: 175820

Answers (9)

Paul Jason
Paul Jason

Reputation: 361

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.

Upvotes: 0

Mauricio
Mauricio

Reputation: 621

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

Upvotes: 9

Rom098
Rom098

Reputation: 2603

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 

Upvotes: 0

damithdev
damithdev

Reputation: 11

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).

Upvotes: 0

Mafei
Mafei

Reputation: 3803

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

Upvotes: 0

Dmytro Lopushanskyy
Dmytro Lopushanskyy

Reputation: 1284

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.

Upvotes: 0

e18r
e18r

Reputation: 8151

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

Upvotes: 15

Eli White
Eli White

Reputation: 1024

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

Upvotes: 14

blotus
blotus

Reputation: 406

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»

Upvotes: 26

Related Questions