title: Go server not hearing remote requests
body: <p>I've written a Go server that works perfectly as long as you send it requests from localhost (and addressed to localhost), but it doesn't work when you try to access it from a browser (from a different computer) or even just directed at the external IP address. I want to be able to access it as an external server, not just locally. Why can't it?</p>
  
  <p>The (pared down) source code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "net"
      "os"
  )
  
  func main() {
      // Listen for incoming connections.
      l, err := net.Listen("tcp", "localhost:2082")
      if err != nil {
          fmt.Println("Error listening:", err.Error())
          os.Exit(1)
      }
      // Close the listener when the application closes.
      defer l.Close()
  
      for {
          // Listen for an incoming connection.
          _, err := l.Accept()
          if err != nil {
              fmt.Println("Error accepting: ", err.Error())
              os.Exit(1)
          }
          fmt.Println("Incoming connection")
      }
  }
  </code></pre>
  
  <p>When you <code>curl localhost:2082</code>, it says "Incoming connection".<br>
  When you <code>curl mydomain.com:2082</code>, it does nothing.</p>
  
  <p>The port <strong>is forwarded</strong>. I'm sure of this because I ran a (node.js) web server from that port, and it worked fine. If it's related, I'm running on Ubuntu 12.04 on an Amazon EC2 instance.</p>
  
  <p>I'd appreciate any help. Thanks!</p>