title: Open Port in Ubuntu
body: <p>So I'm using AWS using EC2 and I'm trying to open up a port for Postgresql. In AWS I already have it open:</p>
  
  <pre><code>TCP
  Port (Service)      Source                  Action
  0 - 65535           sg-92aadda2 (default)   Delete
  22 (SSH)            0.0.0.0/0               Delete
  80 (HTTP)           0.0.0.0/0               Delete
  5432                0.0.0.0/0               Delete
  </code></pre>
  
  <p>When I do netstat it looks as though the port is listening:</p>
  
  <pre><code># netstat -an | grep 5432
  tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN
  </code></pre>
  
  <p>When I do a localhost nmap I get the following:</p>
  
  <pre><code> Nmap scan report for localhost (127.0.0.1)
   Host is up (0.000010s latency).
   Not shown: 997 closed ports
   PORT      STATE SERVICE
   22/tcp    open  ssh
   80/tcp    open  http
   5432/tcp  open  postgresql
  </code></pre>
  
  <p>And here's where the fun begins. When I do an nmap from an alternative host I get the following:</p>
  
  <pre><code>PORT      STATE  SERVICE
  22/tcp    open   ssh
  80/tcp    open   http
  5432/tcp  closed postgresql
  </code></pre>
  
  <p>I also looked at my iptables to see if I was missing something, but the iptables look empty (which should mean they aren't really doing much)</p>
  
  <pre><code>$ iptables -L
  Chain INPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     all  --  anywhere             anywhere
  REJECT     all  --  anywhere             127.0.0.0/8          reject-with icmp-port-unreachable
  ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
  ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
  ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
  ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
  ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:postgresql
  ACCEPT     icmp --  anywhere             anywhere
  LOG        all  --  anywhere             anywhere             limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
  DROP       all  --  anywhere             anywhere
  
  Chain FORWARD (policy ACCEPT)
  target     prot opt source               destination
  DROP       all  --  anywhere             anywhere
  
  Chain OUTPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     all  --  anywhere             anywhere
  </code></pre>
  
  <p>Am I missing something cause I can't seem to figure out how to access the ip. Whenever I try I get the following error:</p>
  
  <pre><code>Is the server running on host "xx.xx.xx.xx" and accepting TCP/IP connections on port 5432?
  </code></pre>
  
  <p>How do I make it so that I can open up the port so that external servers have access to it? Thanks in advance =) Lemme know if you need any additional data.</p>
  
  <p><strong>EDIT</strong>: As asked below, I tested telnetting, and I was able to telnet into the localhost, but when attempting from the outside I get:</p>
  
  <pre><code>$ telnet xx.xx.xx.xx 5432
  Trying xx.xx.xx.xx...
  telnet: Unable to connect to remote host: Connection refused
  </code></pre>
  
  <p>Also, I double checked and I was properly able to telnet into ssh:</p>
  
  <pre><code>$ telnet xx.xx.xx.xx 22
  Trying xx.xx.xx.xx...
  Connected to xx.xx.xx.xx.
  Escape character is '^]'.
  SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
  </code></pre>