How to Get Hostname


I need to get dynamically hostname in the http request node.How can get the hostname.I have tried this {{$env[“N8N_HOST”]}} but it’s not working.

Thank you


What message are you getting? Using exactly what you provided didn’t work because your quotes are formatted wrong. Using this:

{{  $env["N8N_HOST"]  }}

Should get you either the hostname or the following message:

[access to env vars denied]

If you get the denied error, you need to enable environment variables by using N8N_BLOCK_ENV_ACCESS_IN_NODE .

1 Like

I just did this

Added this to docker_compose.yml
restarted n8n

Access denied - I assume this is a new feature because my env variable access was working before.
Now it still doesnt work with the new setting
Running n8n Version 0.209.0

Yes, you’re right, it appears to be broken. I’m going to try a few other variable modifications to see if it’s just that one or other ones too.

Yup, that would explain it. It works fine when the execution runs automatically.