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 99] Cannot assign requested address #92

Closed
Loxatan opened this issue Mar 29, 2022 · 7 comments
Closed

OSError: [Errno 99] Cannot assign requested address #92

Loxatan opened this issue Mar 29, 2022 · 7 comments

Comments

@Loxatan
Copy link

Loxatan commented Mar 29, 2022

Hi,
thanks for your work and your plugin.
I just tried to install the whole thing on my Matrix server.
Unfortunately I get an error when I try to start the API.

When I try to start the API, I get the following error:

root@vmd76330:~# matrix-registration --config-path /etc/matrix-synapse/registration/config.yaml serve
Traceback (most recent call last):
  File "/usr/local/bin/matrix-registration", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask/cli.py", line 426, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/matrix_registration/app.py", line 58, in run_server
    serve(app, host=config.config.host, port=config.config.port, url_prefix=config.config.base_url)
  File "/usr/local/lib/python3.9/dist-packages/waitress/__init__.py", line 12, in serve
    server = _server(app, **kw)
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 81, in create_server
    last_serv = TcpWSGIServer(
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 239, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 368, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python3.9/dist-packages/waitress/wasyncore.py", line 398, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Cannot assign requested address

My Config looks like this:

server_location: 'http://localhost:8008'
server_name: 'matrix.sleser.de'
registration_shared_secret: 'Same as Homeserver.yaml' # see your synapse's homeserver.yaml
admin_api_shared_secret: 'Admin Token i got from the element app' # to generate tokens via the web api
base_url: 'https://matrix.sleser.de/element/register' # e.g. '/element' for https://example.tld/element/register
client_redirect: 'https://app.element.io/#/login'
client_logo: 'static/images/element-logo.png' # use '{cwd}' for current working directory
db: 'sqlite:///{cwd}db.sqlite3'
host: 'localhost'
port: 5000
rate_limit: ["100 per day", "10 per minute"]
allow_cors: false
ip_logging: false
logging:
  disable_existing_loggers: false
  version: 1
  root:
    level: DEBUG
    handlers: [console, file]
  formatters:
    brief:
      format: '%(name)s - %(levelname)s - %(message)s'
    precise:
      format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
  handlers:
    console:
      class: logging.StreamHandler
      level: INFO
      formatter: brief
      stream: ext://sys.stdout
    file:
      class: logging.handlers.RotatingFileHandler
      formatter: precise
      level: INFO
      filename: m_reg.log
      maxBytes: 10485760 # 10MB
      backupCount: 3
      encoding: utf8
# password requirements
password:
  min_length: 8
# username requirements
username:
  validation_regex: [] #list of regexes that the selected username must match.        Example: '[a-zA-Z]\.[a-zA-Z]'
  invalidation_regex: [] #list of regexes that the selected username must NOT match.  Example: '(admin|support)'

I use a Debian 11 and the Matrix Server runs at the same maschine. I installed nginx and added this to my conf:

server {
    listen 80;
    server_name matrix.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name matrix.sleser.de;

    ssl_certificate /etc/letsencrypt/live/matrix.sleser.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/matrix.sleser.de/privkey.pem;

    location / {
        proxy_pass http://localhost:8008;
        proxy_set_header X-Forwarded-For $remote_addr;
        # Nginx by default only allows file uploads up to 1M in size
        # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
        client_max_body_size 10M;
    }
    location  ~ ^/(static|register) {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:5000;
    }

}

# This is used for Matrix Federation
# which is using default TCP port '8448'
server {
    listen 8448 ssl;
    server_name matrix.sleser.de;

    ssl_certificate /etc/letsencrypt/live/matrix.sleser.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/matrix.sleser.de/privkey.pem;

    location / {
        proxy_pass http://localhost:8008;
        proxy_set_header X-Forwarded-For $remote_addr;

}

I am new to the whole Matrix topic and hope I am not making an essential mistake. I am very grateful for any help.
Many greetings

@xelantro
Copy link
Collaborator

Your base_url: 'https://matrix.sleser.de/element/register' is wrong.
It should be base_url: '/element' for https://matrix.sleser.de/element/register
I'm not sure weather this is the core issue, but try changing that

@Loxatan
Copy link
Author

Loxatan commented Mar 29, 2022

Hey, thanks for your fast replay.
I changed it to '/element' but i still got the same error

root@vmd76330:~# matrix-registration --config-path /etc/matrix-synapse/registration/config.yaml serve
Traceback (most recent call last):
  File "/usr/local/bin/matrix-registration", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/flask/cli.py", line 426, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/matrix_registration/app.py", line 58, in run_server
    serve(app, host=config.config.host, port=config.config.port, url_prefix=config.config.base_url)
  File "/usr/local/lib/python3.9/dist-packages/waitress/__init__.py", line 12, in serve
    server = _server(app, **kw)
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 81, in create_server
    last_serv = TcpWSGIServer(
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 239, in __init__
    self.bind_server_socket()
  File "/usr/local/lib/python3.9/dist-packages/waitress/server.py", line 368, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/local/lib/python3.9/dist-packages/waitress/wasyncore.py", line 398, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Cannot assign requested address

i had to change the bind_addresses in my homerserver.yaml config: ['::1', '127.0.0.1'] to 'localhost', otherwise the server did not start, can it be a similar problem? In the matrix-registration config its host = 'localhost', but maybe in another module?

@xelantro
Copy link
Collaborator

Ok so the error serve(app, host=config.config.host, port=config.config.port, url_prefix=config.config.base_url) indicates that you have problems in either:

  • host (try changing that to the ip that ping localhost gives you or 0.0.0.0)
  • port (is 5000 still free?)
  • base_url (you fixed that)

@Loxatan
Copy link
Author

Loxatan commented Mar 29, 2022

ping localhost gave me 127.0.0.1 and i changed it.
Now it works and i can open http://localhost:5000/register.
Thank you very much.

Now I just need to make it accessible via the domain, that doesn't work yet. So neither from the server nor from the computer.
I have so far no firewall, maybe an idea what it could be?

@Loxatan
Copy link
Author

Loxatan commented Mar 29, 2022

I found the error, is because I use https, adjusted the Ngnix Matrix.conf and now I get to the page, however I can not interact with it.
image

@xelantro
Copy link
Collaborator

xelantro commented Mar 29, 2022

You set base_url: '/element' but you seem to want it to be https://matrix.sleser.de/register?lang=de not https://matrix.sleser.de/element/register?lang=de right? (judjing from your location ~ ^/(static|register) nginx config)
If so you need to set it to base_url: ''

@Loxatan
Copy link
Author

Loxatan commented Mar 29, 2022

Okay i guess i understand it now..
I changed it and now it works fine, thank you very much, you saved my evening.
Thank you for your patience :)

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

2 participants