Incoming s2s stream auth.jitsi.homenet.com->localhost closed: This host does not serve localhost

I was trying to setup a self-hosting Jitsi.

Up till now, I can start a meeting. However, there are errors in the Jicofo.

Jicofo logs:

Jicofo 2021-12-14 21:15:10.296 INFO: [1] Main.main#49: Starting Jicofo.
Jicofo 2021-12-14 21:15:11.207 INFO: [1] JitsiConfig.<clinit>#47: Initialized newConfig: merge of /etc/jitsi/jicofo/jicofo.conf: 1,system properties,reference.conf @ jar:file:/usr/share/jicofo/jicofo.jar!/reference.conf: 1
Jicofo 2021-12-14 21:15:11.219 INFO: [1] ReadOnlyConfigurationService.reloadConfiguration#51: loading config file at path /etc/jitsi/jicofo/sip-communicator.properties
Jicofo 2021-12-14 21:15:11.223 INFO: [1] ReadOnlyConfigurationService.reloadConfiguration#56: Error loading config file: java.io.FileNotFoundException: /etc/jitsi/jicofo/sip-communicator.properties (No such file or directory)
Jicofo 2021-12-14 21:15:11.228 INFO: [1] JitsiConfig.<clinit>#68: Initialized legacyConfig: sip communicator props (no description provided)
Jicofo 2021-12-14 21:15:11.236 INFO: [1] JitsiConfig$Companion.reloadNewConfig#94: Reloading the Typesafe config source (previously reloaded 0 times).
Jicofo 2021-12-14 21:15:13.463 WARNING: [1] FocusManager.start#115: Jicofo ID is not set correctly set (value=0). Configure a valid value [1-65535] by setting org.jitsi.jicofo.SHORT_ID in sip-communicator.properties or jicofo.octo.id in jicofo.conf. Future versions will require this for Octo.
Jicofo 2021-12-14 21:15:13.555 INFO: [1] JicofoServices.createAuthenticationAuthority#200: Authentication service disabled.
Jicofo 2021-12-14 21:15:14.452 INFO: [1] XmppServices.<init>#50: No dedicated Service XMPP connection configured, re-using the client XMPP connection.
Jicofo 2021-12-14 21:15:14.465 INFO: [1] XmppServices.<init>#65: No Jigasi detector configured.
Jicofo 2021-12-14 21:15:14.524 INFO: [1] BridgeSelector.<init>#86: Using org.jitsi.jicofo.bridge.SingleBridgeSelectionStrategy
Jicofo 2021-12-14 21:15:14.548 INFO: [1] [type=bridge brewery=jvbbrewery] BaseBrewery.<init>#100: Initialized with JID=jvbbrewery@internal.auth.jitsi.homenet.com
Jicofo 2021-12-14 21:15:14.556 INFO: [1] JicofoServices.<init>#124: No Jibri detector configured.
Jicofo 2021-12-14 21:15:14.559 INFO: [1] JicofoServices.<init>#130: No SIP Jibri detector configured.
Jicofo 2021-12-14 21:15:14.575 INFO: [1] JicofoServices.<init>#145: Starting HTTP server with config: host=null, port=8888, tlsPort=8843, isTls=false, keyStorePath=null, sendServerVersion=true.
Jicofo 2021-12-14 21:15:14.903 INFO: [1] org.eclipse.jetty.util.log.Log.initialized: Logging initialized @5243ms to org.eclipse.jetty.util.log.Slf4jLog
Jicofo 2021-12-14 21:15:15.224 INFO: [1] org.eclipse.jetty.server.Server.doStart: jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 11.0.13+8-LTS
Jicofo 2021-12-14 21:15:16.061 INFO: [15] [xmpp_connection=client] XmppProviderImpl.doConnect#206: Connected, JID=null
Jicofo 2021-12-14 21:15:16.861 WARNING: [15] [xmpp_connection=client] XmppProviderImpl.discoverInfo#363: Failed to discover info
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from localhost: XMPPError: remote-server-not-found - cancel [Server-to-server connection failed: Connecting failed: closed]. Generated by auth.jitsi.homenet.com
        at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:171)
        at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:165)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:284)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:606)
        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:578)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.discoverInfo(XmppProviderImpl.java:356)
        at org.jitsi.jicofo.xmpp.AvModerationHandler.registrationChanged(AvModerationHandler.kt:115)
        at org.jitsi.impl.protocol.xmpp.AbstractXmppProvider.fireRegistrationStateChanged(AbstractXmppProvider.java:88)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.fireRegistrationStateChanged(XmppProviderImpl.java:325)
        at org.jitsi.impl.protocol.xmpp.AbstractXmppProvider.setRegistered(AbstractXmppProvider.java:119)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl$XmppConnectionListener.authenticated(XmppProviderImpl.java:379)
        at org.jivesoftware.smack.AbstractXMPPConnection.callConnectionAuthenticatedListener(AbstractXMPPConnection.java:1710)
        at org.jivesoftware.smack.AbstractXMPPConnection.afterSuccessfulLogin(AbstractXMPPConnection.java:795)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.afterSuccessfulLogin(XMPPTCPConnection.java:371)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginInternal(XMPPTCPConnection.java:469)
        at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:641)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.doConnect(XmppProviderImpl.java:217)
        at org.jitsi.retry.RetryStrategy$TaskRunner.run(RetryStrategy.java:167)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Jicofo 2021-12-14 21:15:16.882 INFO: [15] AvModerationHandler.registrationChanged#123: Did not discover av_moderation component.
Jicofo 2021-12-14 21:15:16.947 WARNING: [15] [xmpp_connection=client] XmppProviderImpl.discoverInfo#363: Failed to discover info
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from localhost: XMPPError: remote-server-not-found - cancel [Server-to-server connection failed: Connecting failed: closed]. Generated by auth.jitsi.homenet.com
        at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:171)
        at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:165)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:284)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:606)
        at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:578)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.discoverInfo(XmppProviderImpl.java:356)
        at org.jitsi.jicofo.xmpp.ConferenceIqHandler.registrationChanged(ConferenceIqHandler.kt:194)
        at org.jitsi.impl.protocol.xmpp.AbstractXmppProvider.fireRegistrationStateChanged(AbstractXmppProvider.java:88)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.fireRegistrationStateChanged(XmppProviderImpl.java:325)
        at org.jitsi.impl.protocol.xmpp.AbstractXmppProvider.setRegistered(AbstractXmppProvider.java:119)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl$XmppConnectionListener.authenticated(XmppProviderImpl.java:379)
        at org.jivesoftware.smack.AbstractXMPPConnection.callConnectionAuthenticatedListener(AbstractXMPPConnection.java:1710)
        at org.jivesoftware.smack.AbstractXMPPConnection.afterSuccessfulLogin(AbstractXMPPConnection.java:795)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.afterSuccessfulLogin(XMPPTCPConnection.java:371)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginInternal(XMPPTCPConnection.java:469)
        at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:641)
        at org.jitsi.impl.protocol.xmpp.XmppProviderImpl.doConnect(XmppProviderImpl.java:217)
        at org.jitsi.retry.RetryStrategy$TaskRunner.run(RetryStrategy.java:167)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Jicofo 2021-12-14 21:15:16.949 INFO: [15] ConferenceIqHandler.registrationChanged#199: No breakout room component address configured.
Jicofo 2021-12-14 21:15:17.031 WARNING: [1] org.glassfish.jersey.server.wadl.WadlFeature.configure: JAXBContext implementation could not be found. WADL feature is disabled.
Jicofo 2021-12-14 21:15:17.446 WARNING: [1] org.glassfish.jersey.internal.inject.Providers.checkProviderRuntime: A provider org.jitsi.rest.Version registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider org.jitsi.rest.Version will be ignored.
Jicofo 2021-12-14 21:15:17.832 INFO: [15] [type=bridge brewery=jvbbrewery] BaseBrewery.start#171: Joined the room.
Jicofo 2021-12-14 21:15:17.835 INFO: [15] [xmpp_connection=client] XmppProviderImpl.fireRegistrationStateChanged#331: Set replyTimeout=PT15S
Jicofo 2021-12-14 21:15:18.466 INFO: [1] org.eclipse.jetty.server.handler.ContextHandler.doStart: Started o.e.j.s.ServletContextHandler@7a3269f5{/,null,AVAILABLE}
Jicofo 2021-12-14 21:15:18.513 INFO: [1] org.eclipse.jetty.server.AbstractConnector.doStart: Started ServerConnector@1549bba7{HTTP/1.1, (http/1.1)}{0.0.0.0:8888}
Jicofo 2021-12-14 21:15:18.514 INFO: [1] org.eclipse.jetty.server.Server.doStart: Started @8859ms

Prosody log:

Dec 14 21:15:14 c2s559e4436f520 info    Client connected
Dec 14 21:15:16 c2s559e4436f520 info    Stream encrypted (TLSv1.3 with TLS_AES_256_GCM_SHA384)
Dec 14 21:15:16 c2s559e4436f520 info    Authenticated as focus@auth.jitsi.homenet.com
Dec 14 21:15:16 auth.jitsi.homenet.com:limits_exception   info    Setting stanza size limits for focus@auth.jitsi.homenet.com to 10485760
Dec 14 21:15:16 s2sin559e443a15e0       info    Incoming s2s stream auth.jitsi.homenet.com->localhost closed: This host does not serve localhost
Dec 14 21:15:16 s2sout559e445943b0      info    Failed in all attempts to connect to localhost
Dec 14 21:15:16 s2sout559e445943b0      info    Sending error replies for 1 queued stanzas because of failed outgoing connection to localhost
Dec 14 21:15:16 s2sin559e444948f0       info    Incoming s2s stream auth.jitsi.homenet.com->localhost closed: This host does not serve localhost
Dec 14 21:15:16 s2sout559e44466b00      info    Failed in all attempts to connect to localhost
Dec 14 21:15:16 s2sout559e44466b00      info    Sending error replies for 1 queued stanzas because of failed outgoing connection to localhost

Prosody config:

plugin_paths = { "/usr/share/jitsi-meet/prosody-plugins/" }

-- domain mapper options, must at least have domain base set to use the mapper
muc_mapper_domain_base = "jitsi.homenet.com";

external_service_secret = "L2WWdN2a86JM7VhF";
external_services = {
     { type = "stun", host = "jitsi.homenet.com", port = 3478 },
     { type = "turn", host = "jitsi.homenet.com", port = 3478, transport = "udp", secret = true, ttl = 86400, algorithm = "turn" },
     { type = "turns", host = "jitsi.homenet.com", port = 5349, transport = "tcp", secret = true, ttl = 86400, algorithm = "turn" }
};

cross_domain_bosh = false;
consider_bosh_secure = true;
-- https_ports = { }; -- Remove this line to prevent listening on port 5284

-- https://ssl-config.mozilla.org/#server=haproxy&version=2.1&config=intermediate&openssl=1.1.0g&guideline=5.4
ssl = {
    protocol = "tlsv1_2+";
    ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
}

unlimited_jids = {
    "focus@auth.jitsi.homenet.com",
    "jvb@auth.jitsi.homenet.com"
}

VirtualHost "jitsi.homenet.com"
    -- enabled = false -- Remove this line to enable this host
    authentication = "anonymous"
    -- Properties below are modified by jitsi-meet-tokens package config
    -- and authentication above is switched to "token"
    --app_id="example_app_id"
    --app_secret="example_app_secret"
    -- Assign this host a certificate for TLS, otherwise it would use the one
    -- set in the global section (if any).
    -- Note that old-style SSL on port 5223 only supports one certificate, and will always
    -- use the global one.
    ssl = {
        key = "/etc/prosody/certs/jitsi.homenet.com.key";
        certificate = "/etc/prosody/certs/jitsi.homenet.com.crt";
    }
    av_moderation_component = "avmoderation.jitsi.homenet.com"
    speakerstats_component = "speakerstats.jitsi.homenet.com"
    conference_duration_component = "conferenceduration.jitsi.homenet.com"
    -- we need bosh
    modules_enabled = {
        "bosh";
        "pubsub";
        "ping"; -- Enable mod_ping
        "speakerstats";
        "external_services";
        "conference_duration";
        "muc_lobby_rooms";
        "muc_breakout_rooms";
        "av_moderation";
    }
    c2s_require_encryption = false
    lobby_muc = "lobby.jitsi.homenet.com"
    breakout_rooms_muc = "breakout.jitsi.homenet.com"
    main_muc = "conference.jitsi.homenet.com"
    -- muc_lobby_whitelist = { "recorder.jitsi.homenet.com" } -- Here we can whitelist jibri to enter lobby enabled rooms

Component "conference.jitsi.homenet.com" "muc"
    restrict_room_creation = true
    storage = "memory"
    modules_enabled = {
        "muc_meeting_id";
        "muc_domain_mapper";
        "polls";
        --"token_verification";
        "muc_rate_limit";
    }
    admins = { "focus@auth.jitsi.homenet.com" }
    muc_room_locking = false
    muc_room_default_public_jids = true

Component "breakout.jitsi.homenet.com" "muc"
    restrict_room_creation = true
    storage = "memory"
    modules_enabled = {
        "muc_meeting_id";
        "muc_domain_mapper";
        --"token_verification";
        "muc_rate_limit";
    }
    admins = { "focus@auth.jitsi.homenet.com" }
    muc_room_locking = false
    muc_room_default_public_jids = true

-- internal muc component
Component "internal.auth.jitsi.homenet.com" "muc"
    storage = "memory"
    modules_enabled = {
        "ping";
    }
    admins = { "focus@auth.jitsi.homenet.com", "jvb@auth.jitsi.homenet.com" }
    muc_room_locking = false
    muc_room_default_public_jids = true

VirtualHost "auth.jitsi.homenet.com"
    ssl = {
        key = "/etc/prosody/certs/auth.jitsi.homenet.com.key";
        certificate = "/etc/prosody/certs/auth.jitsi.homenet.com.crt";
    }
    modules_enabled = {
        "limits_exception";
    }
    authentication = "internal_hashed"

-- Proxy to jicofo's user JID, so that it doesn't have to register as a component.
Component "focus.jitsi.homenet.com" "client_proxy"
    target_address = "focus@auth.jitsi.homenet.com"

Component "speakerstats.jitsi.homenet.com" "speakerstats_component"
    muc_component = "conference.jitsi.homenet.com"

Component "conferenceduration.jitsi.homenet.com" "conference_duration_component"
    muc_component = "conference.jitsi.homenet.com"

Component "avmoderation.jitsi.homenet.com" "av_moderation_component"
    muc_component = "conference.jitsi.homenet.com"

Component "lobby.jitsi.homenet.com" "muc"
    storage = "memory"
    restrict_room_creation = true
    muc_room_locking = false
    muc_room_default_public_jids = true
    modules_enabled = {
        "muc_rate_limit";
    }


I found the problem. When running the jicofo.sh, I missed out the domain and and host which lead to the the Jicofo to use “localhost” to access the Prosody, and was rejected.