Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Connection refused when creating the first user on a fresh Ubuntu server installation #6783

Closed
Klagio opened this issue Jan 26, 2020 · 6 comments

Comments

@Klagio
Copy link

Klagio commented Jan 26, 2020

Followed to the letter (2 different guides) a fresh installation on Ubuntu 16.04 and then 18.04.3 LTS server,

For 18.04 I followed this guide
https://www.howtoforge.com/tutorial/how-to-install-matrix-synapse-on-ubuntu-1804/

When I try to register a new user (my first user) I recieve the below error: this happened on this fresh Ubuntu 18.04 installation, and also on another fresh installation of Ubuntu 16.04 ... so not sure its a bug or what


@ubuntu18matrix:/etc/nginx$ register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml https://127.0.0.1:8448
New user localpart [claudio]:
Password:
Confirm password:
Make admin [no]: yes
Traceback (most recent call last):
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c5f0f3278>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='127.0.0.1', port=8448): Max retries exceeded with url: /_matrix/client/r0/admin/register (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c5f0f3278>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/register_new_matrix_user", line 22, in <module>
    main()
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 225, in main
    args.user, args.password, args.server_url, secret, admin, args.user_type
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 138, in register_new_user
    user, password, server_location, shared_secret, bool(admin), user_type
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/_scripts/register_new_matrix_user.py", line 47, in request_registration
    r = requests.get(url, verify=False)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='127.0.0.1', port=8448): Max retries exceeded with url: /_matrix/client/r0/admin/register (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3c5f0f3278>: Failed to establish a new connection: [Errno 111] Connection refused',))
claudio@ubuntu18matrix:/etc/nginx$ ^C
claudio@ubuntu18matrix:/etc/nginx$ https://matrix.to/#/#synapse:matrix.org

@Klagio
Copy link
Author

Klagio commented Jan 26, 2020

Thats my listeners configuration (I had 127.0.0.1 and tried to changed it with 192.168.1.5 (the LAN static IP), but both configuration gave same error


listeners:
  # TLS-enabled listener: for when matrix traffic is sent directly to synapse.
  #
  # Disabled by default. To enable it, uncomment the following. (Note that you
  # will also need to give Synapse a TLS key and certificate: see the TLS section
  # below.)
  #
  - port: 8448
    type: http
    tls: true
    x_forwarded: false
    bind_addresses: ['192.168.1.5']
    resources:
      - names: [client, federation]

  # Unsecure HTTP listener: for when matrix traffic passes through a reverse proxy
  # that unwraps TLS.
  #
  # If you plan to use a reverse proxy, please see
  # https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md.
  #
  - port: 8008
    tls: false
    type: http
    x_forwarded: false
    bind_addresses: ['192.168.1.5']
    resources:
      - names: [client, federation]
        compress: false

@richvdh
Copy link
Member

richvdh commented Jan 27, 2020

register_new_matrix_user connects to https://localhost:8448 by default, so will fail if your server isn't listening there or doesn't have a valid TLS certificate.

The official installation instructions recommend explicitly specifying http://localhost:8008. If the guides you found give different advice, I suggest you contact the authors of those guides.

See also #3672.

@richvdh richvdh closed this as completed Jan 27, 2020
@melroy89
Copy link

melroy89 commented Oct 4, 2020

When using docker, try:

docker exec -it synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml

Note: synapse is the name of the docker container which should be running.

@Mecallie
Copy link

Mecallie commented Mar 5, 2022

I know this is an old thread, but still: it can also be as simple as the matrix service not running...
systemcpl start matrix.synapse ...

@boscovn
Copy link

boscovn commented Apr 25, 2022

I'm having the same issue despite using http://localhost:8008

@nerdoc
Copy link

nerdoc commented Oct 17, 2023

I have the same problem, running synapse on Uberspace (which is a CentOS 7), managed by supervisord. I am perfectly sure the synapse (and postgresql) services are running, and manage this uberspace by an ansible playbook.
Executing that playbook the first time ALWAYS crashes with the error above, simply running it again creates the user without a problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants