Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:42:40+00:00 2026-06-15T15:42:40+00:00

I keep getting this error [Errno 10061] No connection could be made because the

  • 0

I keep getting this error

[Errno 10061] No connection could be made because the target machine actively refused it.

I’m running Windows 7 64 bit, no virus or protection software, and python is allowed through my firewall (I’ve also tried turning my firewall completely off but same result). When I run the server and use telnet it connects just fine. When I try to connect to the server with the client it fails. Any suggestions as to what I could try to fix this? If you need more information just ask and I’ll provide.

Client Code

import socket
import sys
def main():
   host = ""
   port = 8934
   message = "Hello World!"

   host = raw_input("Enter IP: ")
   #Create Socket
   try:
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   except socket.error, msg:
      print "Failed to create socket. Error code: %s Error Message: %s"%(str(msg[0]),msg[1])
      sys.exit()
   print "Socket created"

   #Connec to Server
   print host
   print port
   s.connect((host,port))
   print "You are connected to %s with IP adress of %s"%(host,host)

   #Send Data
   try:
      s.sendall(message)
   except socket.error:
      print "Failed to send."
   #Receive Data
      reply = s.recv(4096)

if __name__ == "__main__":
   main()

Server Code

# !usr/bin/python

import socket
import sys

HOST = ""
PORT = 8934

def main():
   #Setup socket
   try:
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   except socket.error,msg:
      print "Unable to create socket"
      sys.exit()
   print "Socket created."

   #Bind to adress
   try:
      s.bind((HOST,PORT))
   except socket.error,msg:
      print "Bind failed. Closing..."
      sys.exit()
   print "Socket bound."

   #Start listening
   s.listen(10)
   print "Socket Listening"

   #Accept connection
   conn, addr = s.accept()
   print "Connected to %s:%s"%(addr[0],addr[1])

if __name__ == "__main__":
   main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:42:41+00:00Added an answer on June 15, 2026 at 3:42 pm

    Taking a guess at your indentation, and running your code… it works just fine.* (As long as I type in 127.0.0.1 when it asks me for the IP.)

    Of course the second time I run the client (if I haven’t restarted the server) I get a connection-refused error. But that’s just because you’ve coded a server that immediately quits as soon as it gets the first connection. So the second time you run the client, there is no server, so the OS rejects the connection.

    You can always run the server again, which lets you run the client one more time. (Except that the server may get a 10048 error when it tries to bind the socket, because the OS is keeping it around for the previous owner. If you see that, look at SO_REUSEADDR in the docs.)

    * By “works just fine” I mean that it connects, and prints out the following before quitting:

    Socket created
    127.0.0.1
    8934
    You are connected to 127.0.0.1 with IP adress of 127.0.0.1
    

    Obviously it never sends anything to the server or receives anything back, because the server has no send or recv calls, or anything else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error: DataTables warning: JSON data from server could not be
I keep getting this error after my application is running for 2 days. I've
I keep getting this error in my windows logs: SharePointSocialNetworking.Facebook b0ceb144-b183-4b66-aa10-39fd9ee42bd4 Could not load
I keep getting this error when trying to open a connection using entity framework.
I keep getting this error when I deploy my application in the server machine
I keep getting this error because the VendorID is null for that record. I've
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting this error and have no idea why. I googled and scanned
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.