Hosts-2024.txt — What is it, what does it do and why is it more helpful than it sounds.
Have you ever wanted to run the 2048 game on your own machine locally – either while testing the code you’re going to put onto the web or simply to get a clean version that won’t have half the internet knowing how you play? Well, there’s one little file that makes this significantly easier than it otherwise would be. It is called hosts-2024.txt and it does two things, one of which few people would have thought of.
First of all, what exactly is a hosts file?
There is a file on your computer that has been present since the early days of the modern internet and is rarely acknowledged by its users; however it serves a simple purpose: when your browser tries to go to a website it is asked its name and your computer checks this file first before trying to consult a DNS server. If it finds a match in the file it will then proceed to whatever address you’ve put there. That’s all there is to it-a simple text file of IP addresses and their corresponding domain names-that takes preference over everything else. Quiet, inconspicuous and remarkably powerful.
So what does hosts-2024.txt do?
Two things:
Firstly, local development. The file basically creates a fictitious domain name that can be referred to as 2048.local and then routes that domain straight back to you, so typing in http://2048.local to your browser will launch whatever you have running locally – no need for a server or a domain name, or even having to wait for DNS updates. So you can test the code you’ve written on the machine you’re using as though it was a real website. The following two lines are responsible for making this work.
127.0.0.1 2048.local
::1 2048.local
The first of these will handle IPv4 and the second will deal with IPv6, and both are routed to your own machine.
Second – ad and tracker blocking (optional). This part of the code people tend not to notice until they’ve actually implemented it. The file also contains a commented-out list of all advertising and tracking services – Google Ads, Amazon Ads, Facebook Connect etc – that you can opt into. You just have to remove the # at the start of any of the relevant lines and you can block that particular service system-wide. It’s not one browser, or one tab, anywhere on your machine, because the block takes place before your request has even left your computer.
# 0.0.0.0 pagead2.googlesyndication.com
# 0.0.0.0 ad.doubleclick.net
# 0.0.0.0 google-analytics.com
You remove the #, save the file, done. Something doesn’t work? You put the # back in.
How to use the file
Firstly and most importantly, back up your existing hosts file. You really must do this first.
On Windows, the hosts file can be found at;
- Windows:
C:\Windows\System32\drivers\etc\hosts - macOS / Linux:
/etc/hosts
Copy it somewhere safe and then edit it using administrator rights (Windows) or as root (macOS/Linux). Paste the lines you want to add and save the file. Now if you go to http://2048.local in your browser, you should see the game working.
For the ad and tracker blocking element, just look through the commented lines above and delete the # from whatever you want to block. Thirty seconds, works straight away.
Getting it working on a website
You can easily host this on a website – just copy the HTML, CSS and JS files into a standard index.html file, upload it to your server and you have the game running. If you have a CMS like WordPress and you’re putting the game onto a page, you don’t even need to create the index.html – you can simply open the HTML editor of the page you wish to use and paste the code into there.
It’s free, it’s easy and when you’ve done it you’ll wish you’d been doing it sooner. The hosts file is something that’s just been hiding on your computer for years doing useful things that you never knew about-this just gives you a chance to get round to actually looking at it.


