python socket.gethostbyname() 报错socket.gaierror: [Errno -2] Name or service not known

python socket.gethostbyname() 报错socket.gaierror: [Errno -2] Name or service not known

遇到这个错误可以排查下:

1. 可能是/etc/hosts下面没有配置127.0.0.1 localhost

2. /etc/hostname里的hostname  和 /etc/hosts里的 IP hostname 值不一致。

posted @ 2022-04-13 16:21  123容之  阅读(2971)  评论(0)    收藏  举报