I’m debugging a simple program, that has worked in the past. I’ve singled out the instruction where the error takes place, but I cannot figure out what triggers it. I’ve read all questions related to WinError 10061, but I do not see a clear answer
urllib.request.urlopen('http://www.wikipedia.org/')
Traceback (most recent call last):
File "C:Python33liburllibrequest.py", line 1248, in do_open h.request(req.get_method(), req.selector, req.data, headers)
File "C:Python33libhttpclient.py", line 1061, in request self._send_request(method, url, body, headers)
File "C:Python33libhttpclient.py", line 1099, in _send_request self.endheaders(body)
File "C:Python33libhttpclient.py", line 1057, in endheaders self._send_output(message_body)
File "C:Python33libhttpclient.py", line 902, in _send_output self.send(msg)
File "C:Python33libhttpclient.py", line 840, in send self.connect()
File "C:Python33libhttpclient.py", line 818, in connect self.timeout, self.source_address)
File "C:Python33libsocket.py", line 435, in create_connection raise err
File "C:Python33libsocket.py", line 426, in create_connection sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
urllib.request.urlopen('http://www.wikipedia.org/')
File "C:Python33liburllibrequest.py", line 156, in urlopen return opener.open(url, data, timeout)
File "C:Python33liburllibrequest.py", line 469, in open response = self._open(req, data)
File "C:Python33liburllibrequest.py", line 487, in _open '_open', req)
File "C:Python33liburllibrequest.py", line 447, in _call_chain result = func(*args)
File "C:Python33liburllibrequest.py", line 1268, in http_open return self.do_open(http.client.HTTPConnection, req)
File "C:Python33liburllibrequest.py", line 1251, in do_open raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>
I run Python 3 in Windows 8. I tried turning off the firewall, as a couple of people suggested, but nothing changes. I also tried to add Python to the list of Apps allowed by the firewall. By the way the program line worked without any problem until a few days ago, when I deleted a few Apps from my PC.
Всем привет, прошу помощи специалистов
Собрал свое первое приложение на Python с WEB интерфейсом Eel, затем скомпелировал в .exe файл при помощи Pyinstaller. На моем устройстве на Windows 10 все работает отлично, никаких проблем. Но на других компютерах, тоже Windows 10, вылазит следующая ошибка при попытке отправить запрос на Localhost
ConnectionRefusedError: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
Подскажите пожалуйста, в чем может быть проблема и какие есть варианты решения?
Полный текст ошибки из консоли:
Traceback (most recent call last):
File "urllib3connection.py", line 169, in _new_conn
File "urllib3utilconnection.py", line 96, in create_connection
File "urllib3utilconnection.py", line 86, in create_connection
ConnectionRefusedError: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "urllib3connectionpool.py", line 699, in urlopen
File "urllib3connectionpool.py", line 394, in _make_request
File "urllib3connection.py", line 234, in request
File "httpclient.py", line 1255, in request
File "httpclient.py", line 1301, in _send_request
File "httpclient.py", line 1250, in endheaders
File "httpclient.py", line 1010, in _send_output
File "httpclient.py", line 950, in send
File "urllib3connection.py", line 200, in connect
File "urllib3connection.py", line 181, in _new_conn
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000020635115A00>: Failed to establish a new connection: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "requestsadapters.py", line 439, in send
File "urllib3connectionpool.py", line 755, in urlopen
File "urllib3utilretry.py", line 573, in increment
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=35000): Max retries exceeded with url: /api/v2/profile (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000020635115A00>: Failed to establish a new connection: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "eel__init__.py", line 281, in _process_message
File "main.py", line 80, in get_data
File "main.py", line 167, in update_profile
File "main.py", line 143, in create_profile
File "requestsapi.py", line 119, in post
File "requestsapi.py", line 61, in request
File "requestssessions.py", line 542, in request
File "requestssessions.py", line 655, in send
File "requestsadapters.py", line 516, in send
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=35000): Max retries exceeded with url: /api/v2/profile (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000020635115A00>: Failed to establish a new connection: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение'))
Код функции, в которой возникает ошибка
def create_profile(acc_id):
url = "http://localhost:35000/api/v2/profile"
body = {"name": "Profile" + acc_id,
"browser": "mimic",
"os": "win"
}
header = {
"accept": "application/json",
"Content-Type": "application/json"
}
r = requests.post(url, json.dumps(body), headers=header)
print(r)
print(r.status_code)
uuid = json.loads(r.content).get("uuid")
print("Аккаунт №", acc_id, uuid)
return uuid
- Общий
-
Вопросы
0
Отвечен
Доброго времени суток!
При попытке работать с сервисом обратного геокодирования постоянно получаю ошибку:
httpx.ProxyError: [WinError 10061] No connection could be made because the target machine actively refused it
Подскажите, в чем может быть дело?
интерфейс: api
Ответ
0
Ответ
На рассмотрении
Добрый день! Судя по тексту ошибки, вы используете прокси-сервер. Возможно, он неправильно сконфигурирован и шлет запросы куда-то не туда (не на порт 443, например).
Попробуйте делать запросы без прокси, чтобы локализовать проблему.
- |
-
-
-
Ответы 3
-
Старые сверху- Новые сверху
- Старые сверху
0
Ответ
На рассмотрении
Добрый день! Судя по тексту ошибки, вы используете прокси-сервер. Возможно, он неправильно сконфигурирован и шлет запросы куда-то не туда (не на порт 443, например).
Попробуйте делать запросы без прокси, чтобы локализовать проблему.
- Ответить
- |
-
-
0
Отвечен
Отлично, рад, что разобрались — и спасибо за ссылку!
- Ответить
- |
-
-
Сервис поддержки клиентов работает на платформе UserEcho
I’m trying to send messages from one point to an other, it was working for a while, then when I went back home, it doesn’t work and I get this error:
line 20, in connect
self.mySocket.connect((self.serverName, self.serverPort))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
The code for these are below. I even tried running it on a Mac and I got similar errors.
Client
import socket
serverName = "my_IP_Address"
serverPort = 12000
class User:
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def __init__(self):
self.serverName = serverName
self.serverPort = serverPort
def connect(self):
print("Trying to connect at " + str(self.serverName) + " on port " + str(self.serverPort))
self.mySocket.connect((self.serverName, self.serverPort))
def sendMessage(self, msg):
newS = msg.encode('utf-8')
self.mySocket.send(newS)
modifiedData = self.mySocket.recv(2048)
def closeSocket(self):
self.mySocket.close()
def listen(self):
self.mySocket.bind(('', self.serverPort))
self.mySocket.listen(1)
print("We are ready to receive data on port " + str(serverPort))
while (1):
print("** attempting ** ")
connectionSocket, addr = self.mySocket.accept()
rcvMsg = connectionSocket.recv(2048)
newMsg = "I have received: " + rcvMsg.decode('utf-8')
print(newMsg)
newMsg = newMsg.encode('utf-8')
connectionSocket.send(newMsg)
connectionSocket.close()
if (rcvMsg.decode('utf-8') == 'done'):
break
print("done listening")
def main():
userA = User()
userA.listen()
main()
Server
def main():
userA = User()
userA.connect()
msg = "Hello from the lab"
while(msg != "done"):
userA.sendMessage(msg)
msg = input("please type another message to send: ")
print("done transmitting messages")
main()
Any direction would be greatly appreciated!
when running WebSocketManager example met a error:
Traceback (most recent call last):
File "D:testpythonwebsockets-masterexampleCopy of ws4py_server.py", line 24, in <module>
client.connect()
File "C:Python34libsite-packagesws4pyclient__init__.py", line 209, in connect
self.sock.connect(self.bind_addr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
the client example on https://ws4py.readthedocs.org/en/latest/sources/managertutorial/
os: windows xp sp3, python3.4
God… you’re not lucky today. I will try to have a look asap. Sorry.
I’m wondering if it’s not a limit in your Windows settings. XP isn’t known for being server friendly.
I modify 2000 clients to 20 clients, the error is still exists.
Indeed. I just tried and it seems Windows doesn’t quite like using «localhost». Could you change the «localhost» part to «127.0.0.1» (or your real ip) in the manager example above please? It did work for me.
no, this error is still exists, Regardless use «127.0.0.1» or «192.168.1.100»(my real ip).
but, run other example, use the same ip and port, it’s ok.
This is weird. I just tried (mind you on a Windows 7) and it worked just fine (not that fast though since on Windows, we’re bound to use select which is rather crap).
under win7 64bit, have the same error(ConnectionRefusedError).
I find out the reason of this error.
Must start server before client. if no server running, the client will meet ConnectionRefusedError.
I made a low level mistake.
Close this issue, please.
thank you.
Melik97, Ali-Nass, sushi-545, lebenito, Danita, PTaHHHa, arun-ajay, and cs17b003-Abishekh-P reacted with laugh emoji
Genza999, Ranchonyx, evelyn9191, Melik97, sushi-545, lebenito, saidamef, ConorMeade, Gowtham-mg, cs17b003-Abishekh-P, and tamarAndEsti reacted with heart emoji
lebenito, alecolu95, basirpayenda, and cs17b003-Abishekh-P reacted with eyes emoji
ypid
mentioned this issue
Jan 25, 2015
Hello, I have a similar issue. Do we have to put anything in the password if we do it via Windows Authentication via logging in via SQL Server Management Studio. Any help would be appreciated. Thank you!
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it iam getting this error plz help
When installing MongoDB, you have ‘complete’ and ‘custom’ option. Go with ‘custom’ option. It solved this issue for me. Not sure why though.
I have the same error but I have already started the server before client.
@zaazbb at #130 I did the same (placed the started the server before) but still having the same issue. Could you please help me?
Hey all, I haven’t looked at this project for a long time so I apologise again if it is frustrating to you. I have moved one indeed.
However, if there is a PR with fix someday for this one from the community, I’ll be happy to release it.
This error is raised when the client has failed to connect to the server.
- Ensure that your server is started this means that;
->the server has bind to the address and port and listening to an incoming connection
I don’t know why this issue is closed I have same error as most of you guys i.e «ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it».
Anyway i tried every possible solution mentioned in above list :
- Killing the application (IDE) — to check if any previous thread is holding the resource.
- socket.close and socket shutdown to release the socket after use
- running the server before the client
- changing address from ‘localhost’ to ‘127.0.0.1’
- changing the port from 50000 to other values.
apparently none of this had worked for me.
found the solution after spending 2 hours of search
server.py file
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = '' port = 5555 s.bind((host, port)) s.listen(5) while True: c, addr = s.accept() print('Got connection from', addr) c.send(b'Thank you for connecting') c.close()
client.py file
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = 'server ip address..' port = 5555 try: s.bind((host, port)) except socket.error as e: print(str(e)) s.connect((host, port)) print(s.recv(1024)) s.close()
This worked for me. other solution like changing to ‘localhost’ or ‘127.0.0.1’ didn’t worked.
and you must start the server before client.
server is window machine and client is ubuntu machine.
Thank you so much for efforts to send the solution I will definitely try
this method.
Regards,
Shrinath Chede
…
On Tue, 26 Feb 2019 at 12:39 PM, rednivrug ***@***.***> wrote:
found the solution after spending 2 hours of search
server.py file
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host =
» port = 5555 s.bind((host, port)) s.listen(5) while True: c, addr =
s.accept() print(‘Got connection from’, addr) c.send(b’Thank you for
connecting’) c.close()
client.py file
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host =
‘server ip address..’ port = 5555 try: s.bind((host, port)) except
socket.error as e: print(str(e)) s.connect((host, port))
print(s.recv(1024)) s.close()
This worked for me.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AmdlOyHbjC_JL0EJnE-xDWPtOpXfl4s4ks5vRR0HgaJpZM4ByLyA>
.
I was able to resolve it by setting (debug=False) on my Flask server. It worked for both (localhost, and 127.0.0.1). Hope that works for some folks!
change the port to 8080 or 8888 and the host to socket.gethostname()
hope it will help as it did help me
if the problem still exist please share the code
Make sure that the value of IP address in server is exactly same for your client. Since client will connect to the server. Unfortunately the server will work only on 127.0.0.1 which is your machine and all other shall not work until you make your own virtual machine. On Unix systems this functionality will work on 127.0.. , but on windows only on 127.0.0.1.
This is tested by me and its documentation is available on page number 12 of the book Foundation of Python Programming — Third edition, Brandon, John.
I was getting the same error .. make sure you are working on 3306 port if it isn’t then add port=»3307″ or whatever port you are working on in the mysql.connector.connect line
mydb = mysql.connector.connect(host = «127.0.0.1»,port= «3307» ,user = «root»,passwd=»gautam4?»)«
if you are using wamp or xamp like software run it before you ran the command
«python manage.py runserver»
this is related with settings means if you are using mysql connection in your program
All i did was run «mongod», and tried connecting. The mongodb server needed to start.
Why was this issue closed? I couldn’t find what solution was provided… !? How and where should I have started running before making the call?
am having the same issue whenever i use dj rest auth for django
I think, at this stage, most comments here are related to the common connection error that can occur on any software. They don’t seem to be related to ws4py. I will therefore lock this issue.
Repository owner
locked as off-topic and limited conversation to collaborators
May 1, 2020