We have moved to a new Sailfish OS Forum. Please start new discussions there.

HowTo: Block websites in every browser

asked 2015-11-29 13:31:26 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2015-11-29 21:52:41 +0300

DrBlock42 gravatar image

To block certain websites in every browser on your Jolla Phone, follow these simple steps:

Blocking websites

  1. Make sure you have a Jolla account and the Jolla device can access the Jolla Store.

  2. Go to |- Settings | System Settings | Developer Mode -|.

  3. Activate „Developer mode“. Because your Jolla device can access the Jolla Store, a Terminal app is installed now.

  4. Activate „Remote connection” (either enter and [Save] a password or [Generate] it; if you generate it, you have to edit it slightly before the [Save] button becomes available).

  5. Open the Terminal app installed during step 2. The SailfishOS command prompt will appear. You are logged in as user, the prompt is a "$".

  6. Get root access:
    Enter devel-su [Enter].

  7. When requested: Enter your password (as specified during step 4) and [Enter]. The prompt changes from "$" to "#". Now, you have root access to the Jolla device! Be careful!

  8. Go to root:
    Enter cd /[Enter]

  9. Create a backup of the hosts-file:
    Enter cp /etc/hosts /etc/hosts.bkp [Enter]

  10. Add Website you want to block to the file (e.g. www.google.com):
    Enter sh -c 'echo " www.google.com" >> /etc/hosts'[Enter]
    (Do only change the adress, nothing else!)

    Important:Do not forgett "www." and remember that some websites like facebook do have a mobile version aswell (m.facebook.com)

  11. Repeat Step 10 for every website you want to block. This can be done at any point in time.

How it works: Basicly you are telling you're phone to redirect every request for the specified websites back to the phone itself. That comes handy when you have a html-server running on your phone with a custum html file with e.g. a warning. Without a server it will simply say: Connection Error as if the site would not exist.

Reloading BackUp

If you want to unblock all websites, simply restore the backup:
Enter cp /etc/hosts.bkp /etc/hosts [Enter]

Then agree to overwrite the file: y [Enter]

PS: Some steps are copied from https://together.jolla.com/question/30926/howto-install-google-play/ beacuse they're identical.

edit retag flag offensive close delete


This is the same principle used here to do ad blocking: https://together.jolla.com/question/28922/how-to-adblock-for-sailfish-browser/#post-id-53277

drcouzelis ( 2015-11-30 15:46:37 +0300 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-11-29 13:42:52 +0300

Mano gravatar image

updated 2015-11-29 13:43:11 +0300

You are mixing domain names with host names. In /etc/hosts, you can only define hosts. In your case, you'll be pinging if you ask for "google.de" but not if you ask for "www.google.de" You need to add www.google.de to /etc/hosts instead of google.de Which wasn't of much use probably, depinding what your intention is. If it has to do with privacy, this method wouldn't last at all, neither if you'd maintain a complete hosname list :-(


edit flag offensive delete publish link more


google.de was just an example. I want to block websites that distract me from working^^

DrBlock42 ( 2015-11-29 14:01:40 +0300 )edit

Thank you very much :) It did work

DrBlock42 ( 2015-11-29 14:42:05 +0300 )edit

One last question: Is there an easy way to redirect these domains to a local html file (that says for example: "Get back to work!!!" :) ).

DrBlock42 ( 2015-11-29 14:47:31 +0300 )edit

@DrBlock42 Well, you can install apache (https://openrepos.net/content/nieldk/apache) and put a simple html file with "Get back to work!!!" in it :-D

ced117 ( 2015-11-29 15:05:59 +0300 )edit

@ced117 Sorry I'm a big Linux-Noob (I usually just copy-paste everything) so I have no clue how to get this working:
1. Where do I have to put index.html?
2. How do I start the apache server?
3. How do I add the Server to autostart?
PS: I already installed apache through the Warehouse app

DrBlock42 ( 2015-11-29 15:51:49 +0300 )edit
Login/Signup to Answer

Question tools

1 follower


Asked: 2015-11-29 13:31:26 +0300

Seen: 705 times

Last updated: Nov 29 '15