Node Express “favicon.ico” not found error

Posted on

Node Express “favicon.ico” not found error

I’m trying to download a photo through a URL passed as a query string using Express, but every time I try to use it, I get Error: Invalid URI "favicon.ico" Is there a way I can get my browser to stop requesting a favicon? For downloading images, I’m using the image-downloader package (NPM page)


app.get('/:url', (req, res) => {
let url = req.params.url;
const options = {
    url: url,
    dest: /path'
    .then(({ filename, image }) => {
        console.log('File saved to ', filename);
    .catch((err) => {


Solution :

It’s probably easiest to just make a route for favicon.ico in your server.

app.get('/favico.ico', (req, res) => {

Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.

FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.

If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:

app.get('/favico.ico', (req, res) => {

Try using another package like request module. I believe it got this type of things handled.

var fs = require('fs'),
request = require('request');

var download = function(uri, filename, callback){
  request.head(uri, function(err, res, body){
    console.log('content-type:', res.headers['content-type']);
    console.log('content-length:', res.headers['content-length']);

    request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);

download('', 'google.png', function(){

Leave a Reply

Your email address will not be published. Required fields are marked *