# Nginx listen to $hostname doesn't work, is it supported?

**URL:** <https://www.ruby-forum.com/t/nginx-listen-to-hostname-doesnt-work-is-it-supported/224885>\
**Category:** NGINX\
**Created:** [November 29, 2012, 10:02pm UTC](https://www.ruby-forum.com/t/nginx-listen-to-hostname-doesnt-work-is-it-supported/224885 "2012-11-29T22:02:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 29, 2012, 10:02pm UTC](https://www.ruby-forum.com/t/nginx-listen-to-hostname-doesnt-work-is-it-supported/224885/1 "2012-11-29T22:02:24Z")

</div>

n my nginx conf file, I have :

listen 80;  
server\_name $hostname;

if I do netstat I see that it is listening on 0.0.0.0:80 , is there any  
workaround in nginx.conf , to make it listen to $hostname:80 ? where  
$hostname is coming from system ?

I tried multiple combinations with no success so far.

Thanks

Posted at Nginx Forum:

> **[nginx listen to $hostname doesn't work, is it supported?](https://forum.nginx.org/read.php?2,233398,233398#msg-233398)**
>
> n my nginx conf file, I have : listen 80; server\_name $hostname; if I do netstat I see that it is listening on 0.0.0.0:80 , is there any workaround in nginx.conf , to make it listen to $hostname:80 ? where $hostname is coming from system ?

---

<div class="post-metadata">

**Author:** ![coral](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5ac83/32.png) [@coral](https://www.ruby-forum.com/u/coral)\
**Post date:** [November 30, 2012, 6:33am UTC](https://www.ruby-forum.com/t/nginx-listen-to-hostname-doesnt-work-is-it-supported/224885/2 "2012-11-30T06:33:08Z")

</div>

Hi,

On Fri, Nov 30, 2012 at 5:01 AM, coral [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Why not just use ‘localhost’? For example:  
listen localhost:80;

Regards,
