Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the hosts file for blocking websites, and when we try to open that website the browser shows some default message, but I need to display my own message.

Is there any possibility for displaying a user-defined message?

share|improve this question
Of course, a hosts file is the wrong tool for this job – JdeBP Dec 7 '11 at 23:39

Run a web-server on your local machine on the usual port (80) and set a custom error page

In your hosts file use as the address for blocked domains


If you have Perl installed, you can use something like this (start it from a command prompt)

use strict;
use warnings;
use HTTP::Daemon;
use HTTP::Status;

my $d = HTTP::Daemon->new(LocalPort => 80);

while (my $c = $d->accept) {
    while (my $r = $c->get_request) {

Other scripting languages are available. Batteries not included.

share|improve this answer
how to run web-server on port (80),. Can you please explain clearly – vijay P Dec 7 '11 at 14:26
@vijayP: First select a simple web server. If you are a Windows user, you might want to use IIS. Second, read it's documentation. Third, if you can't see how to set a custom page for 404 errors, ask here (or maybe in – RedGrittyBrick Dec 7 '11 at 14:44
@vijayP: Answer updated – RedGrittyBrick Dec 7 '11 at 15:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.