I'm trying to setup a hidden service, I've tunneled my server though tor, however things like gethostbyname is leaking my real ip address, I have no clue why its doing that, while curl doesn't....

Is there anything I'm missing.

  • What OS? And do you run apache, nginx or something else? Does webbrowser also leak ip after it's been torified? ( with for example check.torproject.org )
    – IAmNoone
    Jan 22, 2016 at 21:34

1 Answer 1


an answer is simple, not tied to PHP only :

  1. Use, etc dedicated localhost-like IPs for each of dedicated hidden services. Do not use subnet at all - it will expose your localhost!
  2. Use ISC bind for all dns lookups on a host. Pair it with Tor DNS port, and in a reverse zone assign xxx-dot-onion names to IP's from pt.1
  3. As a backup for pt.2 use /etc/hosts file
  4. In your service's webserver bind the server to IP's from pt.1 and suppy a corresponding hostnames to virtualhosts

That's it!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .