OSError:[Errno 48]地址已在使用中 [英] OSError: [Errno 48] Address already in use

查看:77
本文介绍了OSError:[Errno 48]地址已在使用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Mac终端设置服务器.我已经在端口5000上建立了连接,并想在5002中打开另一个端口. 导航到文件夹位置后:

I'm trying to setup a server from Mac terminal. I've established a connection on port 5000 and want to open another port in 5002. After navigating to the folder location:

python Blockchain.py -p 5002

但这会导致错误:

OSError: [Errno 48] Address already in use

我在同一问题上提到了各种答案:

I've referred various answers on the same issue:

[ socket.error:[Errno 48]地址已在使用中

[烧瓶和pycharm socket.error

[ Python-套接字错误,正在使用地址

此外,我尝试了以下方法来解决此问题:

Also, I tried the following methods to resolve the issue:

  1. 重启终端
  2. 重新启动PyCharm
  3. 在不同的套接字上运行(给出相同的错误).

这似乎都不起作用.我是Python的新手.错误消息如下: python Blockchain.py -p 5002 Traceback (most recent call last): File "Blockchain.py", line 290, in <module> app.run(host='0.0.0.0', port=5000) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/flask/app.py", line 841, in run run_simple(host, port, self, **options) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 814, in run_simple inner() File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 774, in inner fd=fd) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 666, in make_server passthrough_errors, ssl_context, fd=fd) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 577, in __init__ self.address_family), handler) File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 453, in __init__ self.server_bind() File "/anaconda/envs/blockchain/lib/python3.6/http/server.py", line 136, in server_bind socketserver.TCPServer.server_bind(self) File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 467, in server_bind self.socket.bind(self.server_address) OSError: [Errno 48] Address already in use

None of that seems to work. I'm fairly new to Python. Error message attached below: python Blockchain.py -p 5002 Traceback (most recent call last): File "Blockchain.py", line 290, in <module> app.run(host='0.0.0.0', port=5000) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/flask/app.py", line 841, in run run_simple(host, port, self, **options) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 814, in run_simple inner() File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 774, in inner fd=fd) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 666, in make_server passthrough_errors, ssl_context, fd=fd) File "/anaconda/envs/blockchain/lib/python3.6/site-packages/werkzeug/serving.py", line 577, in __init__ self.address_family), handler) File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 453, in __init__ self.server_bind() File "/anaconda/envs/blockchain/lib/python3.6/http/server.py", line 136, in server_bind socketserver.TCPServer.server_bind(self) File "/anaconda/envs/blockchain/lib/python3.6/socketserver.py", line 467, in server_bind self.socket.bind(self.server_address) OSError: [Errno 48] Address already in use

感谢您的帮助.

[1]:socket.error:[Errno 48]地址已在使用中

[1]: socket.error: [Errno 48] Address already in use

[2]:烧瓶和Pycharm套接字错误.

[2]: Flask and Pycharm socket.error

[3]:Python-套接字错误,正在使用地址

[3]: Python - Socket Error, Address In Use

推荐答案

在尝试实现DeepSpace建议的答案时,我偶然发现了以下答案:

While trying to implement answer suggested by DeepSpace I stumbled across the following answer:

https://stackoverflow.com/questions/48205495/python-how-to-run-multiple-flask-apps-from-same-client-machine

https://stackoverflow.com/questions/48205495/python-how-to-run-multiple-flask-apps-from-same-client-machine

要在不同的计算机上运行Flask应用程序,请使用:

To run Flask application on different machines use:

 $ export FLASK_APP=Blockchain.py
 $ flask run --host 0.0.0.0 --port 5000

打开另一个终端并使用:

Open up another terminal and use:

$ export FLASK_APP=Blockchain.py
$ flask run --host 0.0.0.0 --port 5001

信用: https://stackoverflow.com/users/5802335/metmirr

这篇关于OSError:[Errno 48]地址已在使用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆