i got error 10061 in python
<p>im trying to send a message to myself in python but the client code gives me error 10061 the server works properly  it worked just fine but than it suddenly started giving me the error. i tried changing the port but it still gives me the same error</p>

<p>the server </p>

<pre><code>from socket import *
from datetime import *
def main():
    s = socket()
    client_socket = None
    s.bind(("127.0.0.1",8200))
    print "1:time"
    print "2:get list of files"
    print "3:download file"
    print "4:quit"
    input()
    s.listen(1)
    client_socket, client_address = s.accept()
    strn=client_socket.recv(4096)
    if int(strn[0])&gt;4 or int(strn[0])&lt;1:
        print "please send a num between 1-4"
    elif int(strn[0])==1:
        print datetime.time(datetime.now())
    elif int(strn[0])==2:
        folder=raw_input("enter the name of the folder")
        dir(folder)
    client_socket.close()
    s.close()
    input()
if name == '__main__':
        main()
</code></pre>

<p>the client </p>

<pre><code>from socket import *
def main():
    s = socket()
    s.connect(("127.0.0.1",8200))
    buf = raw_input()
    s.send(buf)
    s.close()
    input()
if name == '__main__':
    main()
</code></pre>

<p>the error </p>

<pre><code>Traceback (most recent call last):
  File "D:\client.py", line 10, in &lt;module&gt;
    main()
  File "D:\client.py", line 4, in main
    s.connect(("127.0.0.1",8200))
  File "C:\Python27\lib\socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 10061] No connection could be made because the target machine actively refused it
</code></pre>

<p>10061 error occurs when the target machine refuses a connection.
In your case the most likely reason is the "IP" in s.bind and s.connect try putting an actual IP or 127.0.0.1. It should work</p>

python sockets server