Favicon ico not found responding error 404

Have you ever stumbled upon the famous "Favicon not found" error while checking your website's 404 error logs? Getting this error even though you have a favicon image is annoying, isn't it? This post will explain how to get rid of that error from your logs for good.

Have you ever stumbled upon the famous «Favicon not found» error while checking your website’s 404 error logs? Getting this error even though you have a favicon image is annoying, isn’t it? This post will explain how to get rid of that error from your logs for good.

I quit trying to make sense of why some modern web browsers request resources that are not mentioned on a web page long ago, such as Firefox seeking a favicon icon (favicon.ico) religiously in your website’s root folder, or iOS browsers looking for almost a dozen different apple touch icons (apple-touch-icon-…) with different sizes, as if the Internet will collapse if they are not found. Instead of wishing for web browsers to behave the way I desired as a webmaster, I decided to play the game by its rules and looked for ways to get rid of annoying errors of this kind, even though it meant unproductive additional work.

Briefly speaking, the 404 HTTP status code is triggered when a web browser (client) requests a resource (a page, file, image etc.) on a website (web server) but that resource does not exist or cannot be located correctly. For example, considering our case, if the web browser sends a request to a favicon image file located at,

https://www.tutsandtips.com/favicon.ico

but such a file does not exist, it will create a 404 error which will be sent back to the browser (it won’t be displayed to the user in browser window since it’s not the same as a page not found error or server not found error), as well as logged in the access logs of the website like the following:

«GET /favicon.ico HTTP/1.1» 404

This error log will also be displayed in your traffic stats file (e.g. AWStats), where 404 errors are listed.

Why is «Favicon.ico Not Found» Error Triggered Even Though There is a Favicon Image on My Website?

To answer this question, we need to understand how some web browsers work.

A 404 error being generated for a supposed-to-exist but not-existing file is totally understandable, in fact it is what must happen (and what happens) in order to give a clue to the website administrator to fix such errors. For example, if you forget to upload an image that is linked to from one of your pages, loading that page will (and should) cause a 404 error for that image. Hence, when you see that error in the log, you can upload the image.

What I explained above is the natural and expected behavior of a web browser; however, some browsers do create resource requests (GET) even though they are not linked to or mentioned on your web page. To clarify this, let’s assume you created a favicon image for your website, named it as icon.png and uploaded it to the following location via a free FTP software or via File Manager of your hosting:

https://www.tutsandtips.com/images/icon.png

And you linked to it using the HTML <link> tag, as it is how it is instructed to add a favicon to your website in the HTML specification.

<link rel=»icon» href=»/images/icon.png»>

TIP: You can also refer to our more detailed tutorial about how to add a favicon icon to your website.

Now, while some browsers respect your choice of name and location for your favicon icon (you should be able to name it whatever you want and place it wherever you want, right?) and find it at your specified place with no issues, some other browsers such as Firefox, in an incomprehensible way, insists on seeking «a» favicon icon which is named as favicon.ico and located in the root directory of your site.

/favicon.ico

If it can’t find that file there, then it will cause a 404 error to be generated and logged. This may be a small, negligible thing for some webmasters but for me and I am sure for you too since you are reading this post, it is unacceptable because 1) the browser makes a request for a non-existent file that is not linked to from the page, 2) it causes a 404 error to be generated and logged which keeps you busy while checking your logs, 3) it consumes bandwidth by grabbing the 404 file since it can’t find the favicon.

For the above reasons, I decided to get rid of this error once and for all and came up with the following solution.

The Solution for 404 Favicon Not Found Error

The solution is not the most efficient but it is simple enough and it will help you never see a 404 error for a non-existent favicon.ico in your logs again.

Here are the steps:

STEP 1: Create a .ico file and name it as favicon.ico.

You can use one of the free online graphic design programs and image conversion tools to help you while creating favicons. The favicon file dimensions can be anything from 16×16 pixels and higher; bigger images will look better on mobile phones and tablets when your site is bookmarked like an app. Also don’t forget to optimize the file to save bandwidth. Not recommended tip: If you don’t care about having a favicon, simply create an empty text file -0 bytes- and save it as favicon.ico.

STEP 2: When the favicon icon is ready, upload it to your website’s root directory. The root directory is where the index file (index.html, index.php etc.) is located.

https://www.tutsandtips.com/favicon.ico

STEP 3: Open a web browser and make sure your favicon is accessible by typing its URL (simply replace the domain in the above URL) into the address bar and opening it.

If you can view your favicon, that means it is ready for visitors and browsers. From now on, you will not receive any 404 errors for the favicon image.

TIP: Here are some other solutions to common errors that you might be interested in:
White Question Mark in Black Diamonds Error
No Video with Supported Format and MIME Type Found Error

  • Analytics [83]

  • Console errors [41]

Console errors: «Solution: Refused to load the image ‘http://localhost:8000/favicon.ico’ because it violates the following Content Security Policy directive: “default-src ‘none’”. Note that img-src was not explicitly set, so default-src is used as a fallback — how to fix»

An error appears in the browser console like:

Refused to load the image 'http://localhost:3000/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

localhost/:1 Failed to load resource: the server responded with a status of 404 (Not Found)

the port number can be any: 3002, 4200, 5000, 8000, 8080, 8101, etc.

Similar errors occur when using various server software and frameworks running on NodeJS: Express.JS, Webpack, Angular.js, Ionic framework and so on.

All these errors in the console have a distinctive feature:

loading /favicon.ico from the site’s root is blocked;

presence of the characteristic phrase: because it violates the following Content Security Policy directive: “default-src‘ none ’”. Note that ‘img-src’ was not explicitly set, so ‘default-src’ is used as a fallback., and in the same time the web application itself either does not publish Content Security Policy at all, or publishes another CSP, in which the default-src directive has completely different rules, and the img-src directive may be specified.

A similar error occurs occasionally: Refused to load the font `data:…` because it violates the following Content Security Policy directive: «default-src `none`». Note that `font-src` was not explicitly set, so `default-src` is used as a fallback, it’s not associated with /favicon.ico, but have the same reason.

Why is this happening

When rendering a page, browsers by default request the favicon.ico file, and if the HTML code of the page does not contain a tag indicating the location of the favicon file:

<link rel="icon" type="image/x-icon" href="/static/images/favicon.ico">

then browsers by default request it from the site root — /favicin.ico.

The Safari for iOS browser automatically requests a series of icons of various sizes for different screen sizes of mobile devices, therefore it requires a series of tags:

<link rel="apple-touch-icon" sizes="57x57" href="/static/images/touch-icons/apple-touch-icon-57x57.png">
. . .
<link rel="apple-touch-icon" sizes="180x180" href="/static/images/touch-icons/apple-touch-icon-180x180.png">
<link rel="apple-touch-icon" href="/static/images/touch-icons/apple-touch-icon.png">

If the file /favicon.ico is not in the root of the site, the error «404 Not Found» occurs, and on pages with a status code other than «200 OK», custom headers (including Content Security Policy) are not sent.

Express / Node.JS specifics

If the application does not have its own handler for non-existent pages, the final handler of the used NodeJS framework handles them. Most of these «default handlers», for security reasons, issue a policy Content Security Policy directive: «default-src ‘none'» on such non-existent pages, which appears in messages in the browser console, for example webpack-dev-server:: finalhandler — allow favicon requests.

Recently, this error message has become common in Express/NodeJS applications when accessing non-existent pages. Previously, the finalhandler in NodeJS had a default CSP as default-src ‘self’, so requests to /faficon.ico were not blocked, just in the absence of an icon, the server sent for those 404 «Not Found» without messaging to the console. But after this thread in May 2019 — everything changed and now the default finalhandler has the policy default-src ‘none’. Therefore, everything is now blocked on pages with a 404 code and the Refused to load the image ‘http://localhost:8080/favicon.ico’ Content Security Policy error appears in the console.

Since this error message contains a third party CSP, it is misleading as to the real cause of the error. In fact, this error has nothing to do with Content Security Policy, it often occurs as a result of simple typos in the code.

How to get rid of the error Refused to load the image ‘http://localhost/favicon.ico’ because it violates Content Security Policy

To fix this error, it is enough to get rid of the nonexistent page/image.

• In the case of unexistent favicon.ico, just specify the <link rel=»icon» type=»image/x-icon» tag with the correct location of the favicon file.

Please note that Express will not automatically serve files in the root directory. If you want to place /favicon.ico in your site’s root directory, you will need to add the appropriate logic to your server:

const path = require('path');

app.get('/favicon.ico', (req, res) => {
// Use actual relative path to your .ico file here
res.sendFile(path.resolve(__dirname, '../favicon.ico'));
});

In case of non-existent font, the «404 Not Found» appeared because the route to this page was not registered in the router. In this case an error could be fixed by set the correct static (or dynamic) routing.

The correct way to fix such errors is not to rely on the default error handlers built into NodeJS or frameworks, but to make your own Error pages handler in Express and publish whatever headers you deem necessary.

Blocking of favicon.ico in Firefox

In some cases, Firefox-specific blocking of the favicon.ico occurs:

Content Security Policy: The page’s settings blocked the loading of a resource at http://localhost:8081/favicon.ico ("default-src").

According to the favicon.ico blocked by CSP when fetching JSON on Firefox, Firefox has a built-in JSON Viewer that renders the JSON response using a fancy user interface for easier reading/analysis. In this case, Firefox automatically adds favicon.ico to the rendering page, but JSONViewer overrides CSP.

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Official Flavours Support
  • General Help
  • [SOLVED] Minidlna Can’t find my files

  1. Minidlna Can’t find my files

    Can’t seem to get minidlna working. I have read quite a few posts on getting it working but can’t figure it out. If anyone could assist me in getting it working that would be awesome! I have my minidlna.conf below

    Code:

    # This is the configuration file for the MiniDLNA daemon, a DLNA/UPnP-AV media
    # server.
    #
    # Unless otherwise noted, the commented out options show their default value.
    #
    # On Debian, you can also refer to the minidlna.conf(5) man page for
    # documentation about this file.
    
    # Specify the user name or uid to run as.
    #user=minidlna
    
    
    # Path to the directory you want scanned for media files.
    #
    # This option can be specified more than once if you want multiple directories
    # scanned.
    #
    # If you want to restrict a media_dir to a specific content type, you can
    # prepend the directory name with a letter representing the type (A, P or V),
    # followed by a comma, as so:
    #   * "A" for audio    (eg. media_dir=A,/var/lib/minidlna/music)
    #   * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
    #   * "V" for video    (eg. media_dir=V,/var/lib/minidlna/videos)
    media_dir=V,/home/hooadam/DLNA
    media_dir=V,/home/hooadam/Videos
    media_dir=P,/home/hooadam/Pictures
    
    # Path to the directory that should hold the database and album art cache.
    #db_dir=/home/hooadam/DLNA/db
    
    # Path to the directory that should hold the log file.
    #log_dir=/var/log
    
    # Type and minimum level of importance of messages to be logged.
    #
    # The types are "artwork", "database", "general", "http", "inotify",
    # "metadata", "scanner", "ssdp" and "tivo".
    #
    # The levels are "off", "fatal", "error", "warn", "info" or "debug".
    # "off" turns of logging entirely, "fatal" is the highest level of importance
    # and "debug" the lowest.
    #
    # The types are comma-separated, followed by an equal sign ("="), followed by a
    # level that applies to the preceding types. This can be repeated, separating
    # each of these constructs with a comma.
    #
    # The default is to log all types of messages at the "warn" level.
    #log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn
    
    # Use a different container as the root of the directory tree presented to
    # clients. The possible values are:
    #   * "." - standard container
    #   * "B" - "Browse Directory"
    #   * "M" - "Music"
    #   * "P" - "Pictures"
    #   * "V" - "Video"
    # If you specify "B" and the client device is audio-only then "Music/Folders"
    # will be used as root.
    root_container=.V
    
    # Network interface(s) to bind to (e.g. eth0), comma delimited.
    # This option can be specified more than once.
    network_interface=wlp3s0
    
    
    # IPv4 address to listen on (e.g. 192.0.2.1/24).
    # If omitted, the mask defaults to 24. The IPs are added to those determined
    # from the network_interface option above.
    # This option can be specified more than once.
    # listening_ip=192.168.0.1/24
    
    # Port number for HTTP traffic (descriptions, SOAP, media transfer).
    # This option is mandatory (or it must be specified on the command-line using
    # "-p").
    port=8200
    
    # URL presented to clients (e.g. http://example.com:80).
    #presentation_url=/
    
    # Name that the DLNA server presents to clients.
    # Defaults to "hostname: username".
    friendly_name=UBUNTU_DLNA
    
    # Serial number the server reports to clients.
    # Defaults to 00000000.
    serial=681019810597110
    
    # Model name the server reports to clients.
    #model_name=Windows Media Connect compatible (MiniDLNA)
    
    # Model number the server reports to clients.
    # Defaults to the version number of minidlna.
    #model_number=
    
    # Automatic discovery of new files in the media_dir directory.
    inotify=yes
    
    # List of file names to look for when searching for album art.
    # Names should be delimited with a forward slash ("/").
    # This option can be specified more than once.
    album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
    album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
    album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
    
    # Strictly adhere to DLNA standards.
    # This allows server-side downscaling of very large JPEG images, which may
    # decrease JPEG serving performance on (at least) Sony DLNA products.
    #strict_dlna=no
    
    # Support for streaming .jpg and .mp3 files to a TiVo supporting HMO.
    #enable_tivo=no
    
    # Notify interval, in seconds.
    notify_interval=240
    
    # Path to the MiniSSDPd socket, for MiniSSDPd support.
    #minissdpdsocket=/run/minissdpd.sock


  2. Re: Minidlna Can’t find my files

    Here’s my minidlna.log

    Code:

    [2018/04/05 23:11:45] minidlna.c:1047: warn: Starting MiniDLNA version 1.2.0.
    [2018/04/05 23:11:45] minidlna.c:342: warn: Creating new database at /var/cache/minidlna/files.db
    [2018/04/05 23:11:45] minidlna.c:1087: warn: HTTP listening on port 8200
    [2018/04/05 23:11:45] playlist.c:125: warn: Parsing playlists...
    [2018/04/05 23:11:45] playlist.c:259: warn: Finished parsing playlists.
    [2018/04/05 23:12:19] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:20] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:20] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:20] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:21] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:21] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404
    [2018/04/05 23:12:21] upnphttp.c:1021: warn: /favicon.ico not found, responding ERROR 404


  3. Re: Minidlna Can’t find my files

    Try forcing it to rescan the directories.

    Code:

    sudo service minidlna stop
    sudo rm -rf /var/cache/minidlna/*
    sudo minidlnad -R -d
    sudo service minidlna start

    This deletes any stale index files in /var/cache/minidlna/ then forces a rescan («-R») of the directories. Running with the «-d» switch will display the results of the scan on the terminal. You’ll see the various files flash by on the screen along with large blocks of XML content. When you no longer see either of those, hold down Ctrl and hit C to terminate the process. Then start the daemon using «sudo service minidlna start».

    Rescanning can take a while if you have large archives.

    Last edited by SeijiSensei; April 6th, 2018 at 07:26 AM.


  4. Re: Minidlna Can’t find my files

    Also, check as which user is minidlna running by default. It just may not have access to files in your home directory.


  5. Re: Minidlna Can’t find my files

    Thanks! SeijiSensei that seems to have taken me one step closer because now the web interface shows I have some files now. However I try to find the video files on my phone using VLC it says empty still

    MiniDLNA status
    Media library
    Audio files 0
    Video files 4
    Image files 14


  6. Re: Minidlna Can’t find my files

    Never mind it’s working now I reran your commands and waited longer on the sudo minidlnad -R -d now it’s working. Thanks!!


Bookmarks

Bookmarks


Posting Permissions

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Faulty dependencies trainz как исправить
  • Faultstring a security error was encountered when verifying the message
  • Fault или error
  • Fault mistake error wrong blame defect разница
  • Fault in drive bmw e60 ошибка

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии