Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a subdomain that I want to proxy through Nginx to Node.js.

domain.tld is currently routed the standard way through /opt/nginx/conf/nginx.conf.

However, I also want subdomain.domain.tld to route to domain.tld:8000.

To do this, I put the following in /etc/nginx/sites-available/subdomain.domain.tld.conf:

    server {
            access_log /var/log/nginx/subdomain.domain.log;

            location / {

Nginx seems to start up fine. The subdomain's nameservers are configured correctly.

What am I doing wrong? Thanks a ton for any help in advance.

Edit: Also, I symlinked the file from sites-available/ to sites-enabled/.

Edit: The exact contents of /opt/nginx/conf/nginx.conf:

Edit: The error message starting nginx:

 Starting nginx: nginx: [emerg] bind() to failed (98: Address already in use) 
 nginx: [emerg] bind() to failed (98: Address already in use) 
 nginx: [emerg] bind() to failed (98: Address already in use) 
 nginx: [emerg] bind() to failed (98: Address already in use) 
 nginx: [emerg] bind() to failed (98: Address already in use) 
 nginx: [emerg] still could not bind()
share|improve this question
cross post of… – Dan D. Jan 18 '12 at 1:25
up vote 1 down vote accepted

First off, check for any errors in the log during startup.

It may not be loading this server because of this:


Which should be changed to:


Beyond that, compare the listen directive to that in your other server blocks - make sure it matches. If they're bound to a specific address instead of, then this server wouldn't be getting the requests.


For those who find this question in the future, the subdomain's server block was not being included - and the include block must be within the existing http block to avoid address binding conflicts.

share|improve this answer
I added the http:// to subdomain.domain.tld.conf. In /opt/nginx/conf/nginx.conf, the normal server for domain.tld listens on just "80", would that cause it to not send the request? I need the normal server to listen on port 80 too though, since it needs to serve domain.tld. – element119 Jan 18 '12 at 1:02
Also, I checked both the nginx error and access logs, found nothing. It seems the issue is that the subdomain is getting served to nginx.conf instead of my specific subdomain conf file. – element119 Jan 18 '12 at 1:06
@Archio That ought to work fine, as listen is functionally equivilent to listen 80, at least as far as IPv4 is concerned, but go ahead and change them to match - can't hurt. Can you verify that there's an include in the main config pointing to the sites-enabled directory? – Shane Madden Jan 18 '12 at 1:07
Good call, it wasn't... but now that I included it, it's warning me that is already in use. In other words, it's not letting me bind subdomain.domain.tld to 80 because domain.tld is already using it, I think. – element119 Jan 18 '12 at 1:28
Strange.. as a sanity check, maybe just check lsof -i -P | grep 80 while nginx is stopped? – Shane Madden Jan 18 '12 at 1:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.