How do i connect to Minecraft servers outside my LAN with the new integration?

Hi! I am trying to set up the recently added Minecraft integration. But I can’t connect to any servers outside LAN. For every time I’m trying, i get the following error: Failed to connect to server. Please check the host and port and try again. Also ensure that you are running at least Minecraft version 1.7 on your server.
I have doubled checked that I’m using the right port for every server I’m trying with so that’s not the issue here I think. Is the integration only for LAN servers or am I doing something wrong?

There’s no reason to believe it’s for LAN only servers. It uses the python mcstatus lib

This same service is used for checking your order at McDonalds I think.

Is there anything in the actual logs?

Can your home assistant server ping the minecraft ip addresses directly without the library? (might not be able to if something is blocking ICMP).

There is nothing in the systemlogs that includes minecraft. I am able to ping to the servers through the terminal. I got a new error after i pinged one of the servers that only says Aborted. But just for that specific server so it could be something wrong with just that one.
edit: I just had to restart HA to remove the error I had when i sent this post. But now I’m stuck with the error i sent in the first post.

Keep in mind it only works on the Java version, Bedrock (Xbox One/Windows 10) version isn’t supported.

Yeah I know. I’m trying to connect to a Java server that runs on 1.13.x

Do you have a server you’re willing to post here so we can try?

Or, where can we find a list of public servers?

Try telnet into the server from your Home Assistant machine see if that allows you to connect.

I wanted to share the address but I was afraid to break some advertisement rule . The adress is kottcraft.se

I am quite new to HA so I don’t know how to use telnet here.

Ok, good news is mcstatus can talk to it.

C:\Users\jocnn>python3
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mcstatus import MinecraftServer
>>> srever = MinecraftServer.lookup("kottcraft.se")
>>> server = srever
>>> status = server.status()
>>> print(status)
<mcstatus.pinger.PingResponse object at 0x00000154D75F0A08>
>>> print("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency))
The server has 71 players and replied in 360.034 ms

Now to import it to Home Assistant and see if I can replicate there…

Edit: Nevermind. I’m still on 0.104 and it doesn’t yet have this integration…will have to manually install it real quick

Edit again: Nevermind again lol. Since it was developed in 0.106, it uses functions that don’t even exist in 0.104, so I’d have to either modify it or update to try it.

But, the base library certainly works with servers outside of lan. And kottcraft.se did give a valid response…so not sure what the problem would be.

After asking others that uses the latest version of HA, I noticed that they are facing the same issue. So I guess there is a problem with the integration after all.

Enable debugging and see what the logs say.

I’m not sure how I enable the debugging funcion. But Noting showed up in the logs about the minecraft-server integration.

You can do it from the developer tools:

image

1 Like

It took me a while to get the output but I figured it out :slight_smile:
This is showed up in the log: [homeassistant.components.minecraft_server] Error occurred while trying to ping the server - OSError: [Errno 111] Connection refused

Could be a firewall issue, maybe even SELinux, depends on your setup. Definitely not an issue with the integration.

This looks to be this bug, which is fixed in the latest versions as of 11 days ago. Looking at the error you received, you’re still on an old version (“Error occurred while trying to ping the server” is an old version)

So, if you update home assistant, it should probably be fixed.

2 Likes

That solved it. Thanks for the help!

1 Like

Ah the SRV records. Always forget about those.