Failed to start synapse

My YunoHost server

Hardware: VPS bought online
YunoHost version: 3.7.0.10
I have access to my server : Through SSH
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no
If yes, please explain:

Description of my issue

Hello, i installed synapse but in services the state is always activating

Log of synapse:

2020-03-28 02:25:41,672 - twisted - 192 - ERROR - - File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py”, line 173, in listen_tcp
2020-03-28 02:25:41,672 - twisted - 192 - ERROR - - r.append(reactor.listenTCP(port, factory, backlog, address))
2020-03-28 02:25:41,672 - twisted - 192 - ERROR - - File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/posixbase.py”, line 495, in listenTCP
2020-03-28 02:25:41,673 - twisted - 192 - ERROR - - p.startListening()
2020-03-28 02:25:41,673 - twisted - 192 - ERROR - - File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py”, line 1363, in startListening
2020-03-28 02:25:41,673 - twisted - 192 - ERROR - - raise CannotListenError(self.interface, self.port, le)
2020-03-28 02:25:41,673 - twisted - 192 - ERROR - - twisted.internet.error.CannotListenError: Couldn’t listen on ::1:8008: [Errno 99] Cannot assign requested address.
2020-03-28 02:25:41,676 - synapse.handlers.deactivate_account - 196 - INFO - user_parter_loop-0- User parter finished: stopping
2020-03-28 02:25:41,680 - synapse.handlers.presence - 233 - INFO - presence.on_shutdown-0- Performing _on_shutdown. Persisting 0 unpersisted changes
2020-03-28 02:25:41,681 - synapse.handlers.presence - 244 - INFO - presence.on_shutdown-0- Finished _on_shutdown
2020-03-28 02:25:41,730 - twisted - 192 - CRITICAL - - Unhandled error in Deferred:
2020-03-28 02:25:41,733 - twisted - 192 - CRITICAL - -
Traceback (most recent call last):
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py”, line 1361, in startListening
skt.bind(addr)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py”, line 277, in start
hs.start_listening(listeners)
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py”, line 268, in start_listening
self._listening_services.extend(self._listener_http(config, listener))
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py”, line 160, in _listener_http
reactor=self.get_reactor(),
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py”, line 175, in listen_tcp
check_bind_error(e, address, bind_addresses)
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/init.py”, line 51, in check_bind_error
raise e
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py”, line 173, in listen_tcp
r.append(reactor.listenTCP(port, factory, backlog, address))
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/posixbase.py”, line 495, in listenTCP
p.startListening()
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py”, line 1363, in startListening
raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn’t listen on ::1:8008: [Errno 99] Cannot assign requested address.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py”, line 1418, in _inlineCallbacks
result = g.send(result)
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py”, line 404, in start
_base.start(hs, config.listeners)
File “/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py”, line 287, in start
sys.exit(1)
SystemExit: 1
2020-03-28 02:25:41,748 - twisted - 192 - INFO - - (TLS Port 8448 Closed)
2020-03-28 02:25:41,755 - twisted - 192 - INFO - - Main loop terminated.

I’m just a pretty unknowledgable user, however it seems that the core error in that log is the part:

Couldn’t listen on ::1:8008: [Errno 99] Cannot assign requested address.

What other apps do you have installed/running? Could one of them already be using that port?

How to know that a port is already been using by some app?
These are the services and apps currently running:

“services”: {
“php7.3-fpm”: “running (enabled)”,
“dnsmasq”: “running (enabled)”,
“php7.0-fpm”: “running (enabled)”,
“fail2ban”: “running (enabled)”,
“yunohost-api”: “running (enabled)”,
“mysql”: “running (enabled)”,
“monitorix”: “running (enabled)”,
“glances”: “running (enabled)”,
“pihole-FTL”: “exited (enabled)”,
“rspamd”: “running (enabled)”,
“lufi”: “exited (enabled)”,
“funkwhale-server”: “running (enabled)”,
“avahi-daemon”: “running (enabled)”,
“dovecot”: “running (enabled)”,
“nslcd”: “running (enabled)”,
“coturn-synapse”: “running (enabled)”,
“nginx”: “running (enabled)”,
“ssh”: “running (enabled)”,
“tvheadend”: “running (enabled)”,
“redis-server”: “running (enabled)”,
“funkwhale-beat”: “running (enabled)”,
“postgresql”: “exited (enabled)”,
“metronome”: “running (enabled)”,
“postfix”: “exited (enabled)”,
“yunohost-firewall”: “exited (enabled)”,
“funkwhale-worker”: “running (enabled)”,
“matrix-synapse”: “auto-restart (enabled)”,
“lutim”: “running (enabled)”,
“slapd”: “running (enabled)”
},
“applications”: {
“synapse”: “Synapse”,
“riot”: “Messenger”,
“onlyoffice”: “OnlyOffice”,
“z-push”: “Z-Push”,
“funkwhale”: “Musica”,
“lufi”: “Lufi”,
“rainloop”: “Mail”,
“lutim”: “Imgur”,
“tvheadend”: “Tvheadend”,
“piwigo”: “Piwigo”,
“pihole”: “Pi-hole”,
“monitorix”: “Monitorix”,
“nextcloud”: “Cloud”

well i tried the ss -lntu command and i don’t see the 8008 port being listening

Hello,

Are you sure that IPv6 is enabled on your server ?

1 Like

ipv6? That’s the problem? How do i know if is enabled, in vps admin or in yunohost admin?

Que te retourne la commande ip a show dev lo ?

I was checking as it seems that i don’t have ipv6 configured.

But i checked interfaces config file and indeed was there the ipv6 lines, but i don’t know if are correct as i’m not comfortable with ipv6.

Following this maybe you can try from this : https://unix.stackexchange.com/questions/63794/how-to-check-if-ipv6-is-enabled-on-a-debian-linux

sysctl -a|grep disable_ipv6

Can you share me the result of this ?

Similar error:

2020-03-29 11:08:51,754 - synapse.handlers.deactivate_account - 186 - INFO - user_parter_loop-0- Starting user parter
2020-03-29 11:08:51,759 - synapse.federation.federation_server - 799 - INFO - - Registering federation EDU handler for 'm.receipt'
2020-03-29 11:08:51,762 - synapse.federation.federation_server - 799 - INFO - - Registering federation EDU handler for 'org.matrix.signing_key_update'
2020-03-29 11:08:51,763 - synapse.federation.federation_server - 817 - INFO - - Registering federation query handler for 'client_keys'
2020-03-29 11:08:51,764 - synapse.federation.federation_server - 799 - INFO - - Registering federation EDU handler for 'm.direct_to_device'
2020-03-29 11:08:51,795 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.admin.AdminRestResource object at 0x7fac467e1080> to path b'/_synapse/admin'
2020-03-29 11:08:51,795 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac4d0904e0> to path b'/_matrix/client/unstable'
2020-03-29 11:08:51,796 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac4d0904e0> to path b'/_matrix/client/v2_alpha'
2020-03-29 11:08:51,796 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.well_known.WellKnownResource object at 0x7fac467dacf8> to path b'/.well-known/matrix/client'
2020-03-29 11:08:51,796 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac4d0904e0> to path b'/_matrix/client/api/v1'
2020-03-29 11:08:51,796 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac4d0904e0> to path b'/_matrix/client/versions'
2020-03-29 11:08:51,796 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.federation.transport.server.TransportLayerServer object at 0x7fac467e1240> to path b'/_matrix/federation'
2020-03-29 11:08:51,797 - synapse.util.httpresourcetree - 46 - INFO - - Attaching FilePath('/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/static') to path b'/_matrix/static'
2020-03-29 11:08:51,797 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.media.v1.media_repository.MediaRepositoryResource object at 0x7fac467c0d30> to path b'/_matrix/media/r0'
2020-03-29 11:08:51,797 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.media.v1.media_repository.MediaRepositoryResource object at 0x7fac467c0d30> to path b'/_matrix/media/v1'
2020-03-29 11:08:51,797 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac4d0904e0> to path b'/_matrix/client/r0'
2020-03-29 11:08:51,797 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.key.v2.KeyApiV2Resource object at 0x7fac467c5390> to path b'/_matrix/key/v2'
2020-03-29 11:08:51,799 - twisted - 192 - INFO - - SynapseSite (TLS) starting on 8448
2020-03-29 11:08:51,800 - synapse.app - 48 - WARNING - - Failed to listen on 0.0.0.0, continuing because listening on [::]
2020-03-29 11:08:51,801 - synapse.app.homeserver - 147 - INFO - - Synapse now listening on TCP port 8448 (TLS)
2020-03-29 11:08:51,825 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.admin.AdminRestResource object at 0x7fac4679cba8> to path b'/_synapse/admin'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac467c5cc0> to path b'/_matrix/client/unstable'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac467c5cc0> to path b'/_matrix/client/v2_alpha'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.well_known.WellKnownResource object at 0x7fac467f5a20> to path b'/.well-known/matrix/client'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac467c5cc0> to path b'/_matrix/client/api/v1'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac467c5cc0> to path b'/_matrix/client/versions'
2020-03-29 11:08:51,826 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.federation.transport.server.TransportLayerServer object at 0x7fac4679ce48> to path b'/_matrix/federation'
2020-03-29 11:08:51,827 - synapse.util.httpresourcetree - 46 - INFO - - Attaching FilePath('/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/static') to path b'/_matrix/static'
2020-03-29 11:08:51,827 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.media.v1.media_repository.MediaRepositoryResource object at 0x7fac467c0d30> to path b'/_matrix/media/r0'
2020-03-29 11:08:51,827 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.media.v1.media_repository.MediaRepositoryResource object at 0x7fac467c0d30> to path b'/_matrix/media/v1'
2020-03-29 11:08:51,827 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.ClientRestResource object at 0x7fac467c5cc0> to path b'/_matrix/client/r0'
2020-03-29 11:08:51,827 - synapse.util.httpresourcetree - 46 - INFO - - Attaching <synapse.rest.key.v2.KeyApiV2Resource object at 0x7fac467a2470> to path b'/_matrix/key/v2'
2020-03-29 11:08:51,829 - twisted - 192 - ERROR - - Traceback (most recent call last):
2020-03-29 11:08:51,830 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py", line 1361, in startListening
2020-03-29 11:08:51,831 - twisted - 192 - ERROR - -     skt.bind(addr)
2020-03-29 11:08:51,831 - twisted - 192 - ERROR - - OSError: [Errno 99] Cannot assign requested address
2020-03-29 11:08:51,831 - twisted - 192 - ERROR - - 
2020-03-29 11:08:51,831 - twisted - 192 - ERROR - - During handling of the above exception, another exception occurred:
2020-03-29 11:08:51,832 - twisted - 192 - ERROR - - 
2020-03-29 11:08:51,832 - twisted - 192 - ERROR - - Traceback (most recent call last):
2020-03-29 11:08:51,832 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 277, in start
2020-03-29 11:08:51,832 - twisted - 192 - ERROR - -     hs.start_listening(listeners)
2020-03-29 11:08:51,832 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py", line 268, in start_listening
2020-03-29 11:08:51,833 - twisted - 192 - ERROR - -     self._listening_services.extend(self._listener_http(config, listener))
2020-03-29 11:08:51,833 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py", line 160, in _listener_http
2020-03-29 11:08:51,833 - twisted - 192 - ERROR - -     reactor=self.get_reactor(),
2020-03-29 11:08:51,833 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 175, in listen_tcp
2020-03-29 11:08:51,834 - twisted - 192 - ERROR - -     check_bind_error(e, address, bind_addresses)
2020-03-29 11:08:51,834 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/__init__.py", line 51, in check_bind_error
2020-03-29 11:08:51,834 - twisted - 192 - ERROR - -     raise e
2020-03-29 11:08:51,834 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 173, in listen_tcp
2020-03-29 11:08:51,834 - twisted - 192 - ERROR - -     r.append(reactor.listenTCP(port, factory, backlog, address))
2020-03-29 11:08:51,835 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/posixbase.py", line 495, in listenTCP
2020-03-29 11:08:51,835 - twisted - 192 - ERROR - -     p.startListening()
2020-03-29 11:08:51,835 - twisted - 192 - ERROR - -   File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py", line 1363, in startListening
2020-03-29 11:08:51,835 - twisted - 192 - ERROR - -     raise CannotListenError(self.interface, self.port, le)
2020-03-29 11:08:51,836 - twisted - 192 - ERROR - - twisted.internet.error.CannotListenError: Couldn't listen on ::1:8008: [Errno 99] Cannot assign requested address.
2020-03-29 11:08:51,839 - synapse.handlers.deactivate_account - 196 - INFO - user_parter_loop-0- User parter finished: stopping
2020-03-29 11:08:51,848 - synapse.handlers.presence - 233 - INFO - presence.on_shutdown-0- Performing _on_shutdown. Persisting 0 unpersisted changes
2020-03-29 11:08:51,854 - synapse.handlers.presence - 244 - INFO - presence.on_shutdown-0- Finished _on_shutdown
2020-03-29 11:08:51,890 - twisted - 192 - CRITICAL - - Unhandled error in Deferred:
2020-03-29 11:08:51,891 - twisted - 192 - CRITICAL - - 
Traceback (most recent call last):
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py", line 1361, in startListening
    skt.bind(addr)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 277, in start
    hs.start_listening(listeners)
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py", line 268, in start_listening
    self._listening_services.extend(self._listener_http(config, listener))
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py", line 160, in _listener_http
    reactor=self.get_reactor(),
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 175, in listen_tcp
    check_bind_error(e, address, bind_addresses)
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/__init__.py", line 51, in check_bind_error
    raise e
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 173, in listen_tcp
    r.append(reactor.listenTCP(port, factory, backlog, address))
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/posixbase.py", line 495, in listenTCP
    p.startListening()
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/tcp.py", line 1363, in startListening
    raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on ::1:8008: [Errno 99] Cannot assign requested address.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/homeserver.py", line 404, in start
    _base.start(hs, config.listeners)
  File "/opt/yunohost/matrix-synapse/lib/python3.5/site-packages/synapse/app/_base.py", line 287, in start
    sys.exit(1)
SystemExit: 1
2020-03-29 11:08:51,907 - twisted - 192 - INFO - - (TLS Port 8448 Closed)
2020-03-29 11:08:51,911 - twisted - 192 - INFO - - Main loop terminated.

Output of sysctl -a|grep disable_ipv6 :

sysctl -a|grep disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.all.stable_secret"
net.ipv6.conf.default.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.default.stable_secret"
net.ipv6.conf.docker0.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
net.ipv6.conf.eth0.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
net.ipv6.conf.lo.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.lo.stable_secret"

17

Hello,

Can you check that ipv6 is disabled nowhere with this command:

grep ipv6 -R /etc/sysctl.*

If it’s not the case can you try this, and after check that now IPv6 is enabled:

echo net.ipv6.conf.all.disable_ipv6=0  > /etc/sysctl.d/enableipv6.conf 
sysctl --system

If it’s ok, can you try to reinstall synapse (or just start it if the install didn’t fail).

Hi, thanks by you help

after the second command, the result of the first is the following

But i think the error is still there. Should i restart server or reinstall synapse? By the way i currently have synapse on main tld.com and riot on riot.tld.com. Is that ok?

i tried another command an now i have 3 lines. Is it bad?

Hello,

Well, you need to understand what you do. We need to enable IPv6 on your server. From your first screenshot, I see that there are a line with net.ipv6.conf.all.disable_ipv6=1 whish disable IPv6. In this case the solution is not to add another file where you enable IPv6. You need to enable IPv6 where it’s actually disabled. So what I purpose is:

# Remove the file which force IPv6 up as there are already on an other file which define this parameter
rm /etc/sysctl.d/enableipv6.conf 
# Remove the line 'net.ipv6.conf.all.disable_ipv6=1' and add the line 'net.ipv6.conf.all.disable_ipv6=0' in /etc/sysctl.conf
# You can use this command to edit this file
nano /etc/sysctl.conf

I removed enableipv6.conf, but sysctl.conf already has the line ‘net.ipv6.conf.all.disable_ipv6=0’

Maybe we need to set IPv6 in our DNS too.

No, you need to restart your server, to apply this.

Thanks @Josue the problem is solved, synapse started. yunohost is such a great piece of software :grinning: