Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: [Errno 98] Address already in use #3

Closed
T00rk opened this issue May 14, 2021 · 3 comments
Closed

OSError: [Errno 98] Address already in use #3

T00rk opened this issue May 14, 2021 · 3 comments

Comments

@T00rk
Copy link

T00rk commented May 14, 2021

I tried to make it run on Ubuntu 20.04.2 but it doesn't seem to work.

I got the following error OSError: [Errno 98] Address already in use.

Nothing is running on this address.

flask run
* Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [15/May/2021 00:53:06] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [15/May/2021 00:54:10] "OPTIONS /privacyAPI/v1/ HTTP/1.1" 200 -
usrjson['usrchoice'] =  top_choice
client_secret.json-gmail-v1-(['https://www.googleapis.com/auth/gmail.modify'],)
[2021-05-15 00:54:10,088] ERROR in app: Exception on /privacyAPI/v1/ [POST]
Traceback (most recent call last):
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/t0_0rk/Projets/privacybot/app/app.py", line 32, in executePrivacyAPI
    "return": privacyAPI(usrjson, services)
  File "/home/t0_0rk/Projets/privacybot/app/corefunctions.py", line 259, in privacyAPI
    sendEmail(usrjson, service_map)
  File "/home/t0_0rk/Projets/privacybot/app/corefunctions.py", line 73, in sendEmail
    gmail_service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
  File "/home/t0_0rk/Projets/privacybot/app/Google.py", line 32, in Create_Service
    cred = flow.run_local_server()
  File "/home/t0_0rk/Projets/privacybot/PB_venv/lib/python3.8/site-packages/google_auth_oauthlib/flow.py", line 460, in run_local_server
    local_server = wsgiref.simple_server.make_server(
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 154, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.8/wsgiref/simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
127.0.0.1 - - [15/May/2021 00:54:10] "POST /privacyAPI/v1/ HTTP/1.1" 500 -
@nhevia
Copy link

nhevia commented May 15, 2021

Usually you can change flask port with flash run --port=<number> but XHR in the frontend app is hardcoded to port 5000.

axios.post('http://localhost:5000/privacyAPI/v1/', this.state)

A workaround is to check if you have anything on that port lsof -i and kill the PID if needed.

@T00rk
Copy link
Author

T00rk commented May 15, 2021

It seems to have worked but I was never asked to allow access to gmail or something ...
So when I check my sent mails in Gmail, of course there is nothing ...

@j94c
Copy link
Collaborator

j94c commented May 18, 2021

@nhevia provided the right answer here and also exposed our bad code with the hard coding thing lol - but in fairness Flask running local should default to port 5000. I have seen this specific error before and as @nhevia mentioned killing anything on PID before running and this worked when I ran across this - usually with a random tab / old project in VScode was the culprit/

@j94c j94c closed this as completed May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants