gpt4 book ai didi

sockets - Python socket.error : [Errno 111] Connection refused on ubuntu 12. 04

转载 作者:行者123 更新时间:2023-12-03 11:54:22 27 4
gpt4 key购买 nike

我正在尝试将套接字与 python 一起使用,但我一直收到此错误消息:

import socket
>>> s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
>>> s.connect(('localhost', 8000))
Traceback (most recent call last):
File "stdin", line 1, in module
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

/etc/hosts 中的配置是:

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

系统是ubuntu 12.04,没有配置防火墙。尝试更改端口号,但没有成功;它只适用于不同于 “本地主机”。有人知道为什么会这样吗?

最佳答案

尝试

s = socket.socket( socket.AF_INET6, socket.SOCK_STREAM )
s.connect(('::1', 8000))

您似乎只启用了 ipv6。

关于sockets - Python socket.error : [Errno 111] Connection refused on ubuntu 12. 04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10463965/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com