Setting up a Tor onion service

(Created 2026-03-18)

You’ve probably heard of the ‘scary and illegal’ dark web, only accessible through Tor. Except, it’s neither scary nor illegal (unless used for illegal purposes of course, in most countries) and it’s a great way to host a website privately, for free, from your own home, even if the IPv4 address crisis hit your ISP and they put your network behind a CGNAT. Tor can easily bypass NATs, as only outbound connections are required to make everything work. All you need is a Linux computer connected to the internet, I’m using Ubuntu server because it’s easy to install and setup.

Of course, check your local legislation before proceeding, just in case!

Just enter a bash shell and type the following:

sudo apt install tor

This installs Tor, then you’ll have to enable the Tor service so it starts every time you restart the server

sudo systemctl enable tor 

You can now check the status with

sudo systemctl status tor@default

And it should say something like

● tor@default.service - Anonymizing overlay network for TCP
     Loaded: loaded (/usr/lib/systemd/system/tor@default.service; enabled-runtime; preset: enabled)
     Active: active (running)

Now Tor is installed, and you just have to edit its config file to add a directory for Tor to create some files in, as well as a port and IP mapping so that Tor knows what service you want to expose to the network. For HTTP, pick port 80.

So, edit the file with your favorite text editor

sudo vim /etc/tor/torrc

And add the following lines (or just uncomment them if they’re already present)

HiddenServiceDir /var/lib/tor/{your directory}/
HiddenServicePort 80 127.0.0.1:8080

Make sure to replace {your directory} with a name for a folder for Tor to create the onion service in. Now, any service hosting something on port 8080 is available through the Tor network at port 80. If your HTTP server is using port 80 internally, you could do

HiddenServicePort 80 127.0.0.1:80

instead. (default apache2 config for example)

Now, just restart the tor service and it should work.

sudo systemctl restart tor 

To check what onion address you onion service has, access the file

sudo cat /var/lib/tor/{your directory}/hostname

And you should get a .onion address printed to your terminal, such as

56puj4b3ccrlr63uyoj2mtnwetyhitt4cigzv35ibsipcr7plnau3jid.onion

…which you can finally access in a Tor browser and it should work just fine!