I have my .onion service running:


When i try to open wrong link, my TorBrowser shows me an error like this:

Firefox can’t establish a connection to the server at oeptyn6jtusgda63.onion:7541.

Is there some way i can prevent nginx to leak my server port number?

I have learned myself, that nginx first send redirection (http code 301) that leaks my port number. Is there some way i can disable it?


This happens when i try to access some directory, like this:


  • I experiment the same issue but this solution not working for me. I've try the solution in nginx.conf file and also in the website config file /etc/nginx/site-available/.
    – Zack
    Apr 11, 2019 at 18:14

1 Answer 1


I fixed it myself. I just added this directive to nginx.conf :

port_in_redirect off;

This directive briefly described in nginx doc: https://nginx.org/en/docs/http/ngx_http_core_module.html#port_in_redirect

  • Thanks for posting the solution. Can you accept your own answer so this question can be closed?
    – bn4t
    Jul 3, 2018 at 8:15

You must log in to answer this question.

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