I am trying to run a simple Python TCP server on my EC2, listening on port 6666.  I've created an inbound TCP firewall rule to open port 6666, and there are no restrictions on outgoing ports.
I cannot connect to my instance from the outside world however, testing with telnet or netcat can never make the connection.  Things do work if I make a connection from localhost however.
Any ideas as to what could be wrong?



    #!/usr/bin/env python

    import socket


    TCP_IP = '127.0.0.1'
    TCP_PORT = 6666
    BUFFER_SIZE = 20  # Normally 1024, but we want fast response

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((TCP_IP, TCP_PORT))
    s.listen(1)

    conn, addr = s.accept()
    print 'Connection address:', addr
    while 1:
        data = conn.recv(BUFFER_SIZE)
        if not data: break
        print "received data:", data
        conn.send(data)  # echo
    conn.close()
Your TCP_IP is only listening locally because you set your listening IP to 127.0.0.1.
Set TCP_IP = "0.0.0.0" and it will listen on "all" interfaces including your externally-facing IP.
Simple Python TCP server not working on Amazon EC2 instance