title: nginx error bind Cannot assign requested address
body: <p>I am running Amazon Linux AMI and nginx and when I try starting my nginx server:</p>
  
  <pre><code>$ sudo /etc/init.d/nginx restart
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>nginx: [emerg]: bind() to IP failed (99: Cannot assign requested address)
  </code></pre>
  
  <p>where "IP" is a placeholder for my IP address. Does anybody know why that error might be happening? This is running on EC2.</p>
  
  <p>My nginx.conf file looks like this:</p>
  
  <pre><code>user              app;
  worker_processes  4;
  
  #error_log  /var/log/nginx/error.log;
  #error_log  /var/log/nginx/error.log  notice;
  error_log  /var/log/nginx/error.log  info;
  
  pid        /var/run/nginx.pid;
  
  events {
      worker_connections  1024;
  }
  
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      access_log  /var/log/nginx/access.log;
  
      sendfile        on;
      tcp_nopush     on;
      tcp_nodelay    on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
  
      gzip  on;
      gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/x-javascript application/xml application/xml+rss text/javascript;
  
    server_names_hash_bucket_size 64;
  
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    server {
          listen          IP:443; 
          server_name     name;
          include /etc/nginx/ssl.conf;
    }
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/3191509/nginx-error-99-cannot-assign-requested-address">kirpit</a> say:With Amazon EC2 and elastic IPs, the server doesn't actually know its IP as with most any other server. So you need to tell your linux to allow processes to bind to the non-local address. Just add the following line into /etc/sysctl.conf and then reload your sysctl.conf.</p>
  
  <p>But on Amazon Linux AMI <code>bash: sysctl: command not found</code></p>