• Register
0 votes
4.3k views

Problem :

I am facing the issue with the client and server codes, I keep on getting the [Errno 10061] No connection could be made because the target machine actively refused it

I am running the server on a VM with Windows XP SP3 and my client is on Windows 7 64bit, also my python version is 2.7.3. I want to know is how can I edit the existing code to be able to use the client and server on different networks.

My server code:

#!/usr/bin/python           # This is server.py file
import socket               # Import socket module
s = socket.socket()         # Create a socket object
host = '0.0.0.0' # Get local machine name
port = 12345                # Reserve a port for your service.
print 'Server started!'
print 'Waiting for clients...'
s.bind((host, port))        # Bind to the port
s.listen(5)                 # Now wait for client connection.
c, addr = s.accept()     # Establish connection with client.
print 'Got connection from', addr
while True:
  msg = c.recv(1024)
  print addr, ' >> ', msg
  msg = raw_input('SERVER >> ')
  c.send(msg);
  #c.close()                # Close the connection

My client code :

#!/usr/bin/python           # This is client.py file
import socket               # Import socket module
s = socket.socket()         # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345                # Reserve a port for your service.
print 'Connecting to ', host, port
s.connect((host, port))
while True:
  msg = raw_input('CLIENT >> ')
  s.send(msg)
  msg = s.recv(1024)
  print 'SERVER >> ', msg
#s.close                     # Close the socket when done
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

1) You need to first change directory to root drive C:\, and type the following command into an admin cmd prompt window,

C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg –install

2) After that type net start MongoDB after which you must see the following message:

"The Mongo DB service was started successfully"

3) Then go to the your control panel and go to Start>Administrative Tools>Services, scroll down up to MongoDB in the list of services and please make sure you change the start up type to automatic. Press OK.

4) Finally you need to type C:\mongodb\bin\mongo.exe and you will be connected to the Mongo test DB.

And your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 62 views
62 views
Problem : Why I got the error: [winerror 10061] No connection could be made because the target machine actively refused it.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 5 views
5 views
Problem: I have a problem with these client and server codes, I keep getting the: [Errno 10061] No connection could be made because the target machine actively refused it
asked Apr 26 ummeshani 8.8k points
0 votes
1 answer 68 views
68 views
7 I have a problem with these client and server codes, I keep getting the [Errno 10061] No connection could be made because the target machine actively refused it I'm running the server on a virtual machine with Windows XP SP3 and the client on Windows 7 64bit, my python version is ... msg) msg = s.recv(1024) print 'SERVER >> ', msg #s.close # Close the socket when done PS : code is from internet.
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 5 views
5 views
Problem: The error I keep receiving is (or verbose): #2002 Cannot log in to the MySQL server
asked Apr 25 ummeshani 8.8k points
0 votes
1 answer 4 views
4 views
Problem: I have recently installed Zend Studio and Zend Server with the mysql plugin on Windows 7. The error I keep receiving is (or verbose): #2002 Cannot log in to the MySQL server
asked Apr 25 ummeshani 8.8k points
0 votes
1 answer 6 views
6 views
Problem: No connection could be made because the target machine actively refused it 127.0.0.1:25 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where ... "localhost"; //delete session cookie Response.Cookies["session"].Expires = DateTime.Now.AddYears(-30); SmtpMail.Send(objEmail);
asked Apr 25 muktaa 34.4k points
0 votes
1 answer 6 views
6 views
Problem: Please help me … how can I solve it? no connection could be made because the target machine actively refused it. connection failed
asked Apr 20 Ifra 34.7k points
0 votes
1 answer 128 views
128 views
Problem : I am trying to use the WCF4.0 template -REST. Also I am trying to make the method that uploads a file using the stream. The problem always occur at below line of code: Stream myserverStream = myrequest.GetRequestStream() ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 5 views
5 views
Problem: Trying to solve this problem,"Python socket.error: [Errno 111] Connection refused". Can someone please help me?
asked Apr 18 Supti 12.7k points