Urgent - Connection refused error

Hi Users,

We successfully installed metabase with the help of docker. The metabase we are using connects with mysql that sits on localhost outside the docker.
The metabase gets connected but after some time if its idle we get the following error:

:stacktrace
[“java.base/java.net.PlainSocketImpl.socketConnect(Native Method)”
“java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)”
“java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)”
“java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)”
“java.base/java.net.SocksSocketImpl.connect(Unknown Source)”
“java.base/java.net.Socket.connect(Unknown Source)”
“org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createSocket(AbstractConnectProtocol.java:250)”
“org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:512)”
“org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1367)”
“org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:635)”
“org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)”
“org.mariadb.jdbc.Driver.connect(Driver.java:89)”
“java.sql/java.sql.DriverManager.getConnection(Unknown Source)”
“java.sql/java.sql.DriverManager.getConnection(Unknown Source)”
“–> connection_pool$proxy_data_source$reify__20305.getConnection(connection_pool.clj:29)”],
:context :ad-hoc,
:error “Socket fail to connect to host:localhost, port:42016. Connection refused (Connection refused)”,

This is a real pain can anyone help in here.
Thanks

Hi @David_St

Post “Diagnostic Info” from Admin > Troubleshooting.
Which version of MySQL?
Are you using SSH tunnel?

There’s something wrong, since localhost inside of a container is the container itself - not the host.
That doesn’t make sense.

If you write “Urgent” in a topic, then you should provide more information.

Hi Flamber

Thanks for getting into the conversation here. My version of maria DB is 10.3.24 which is above the minimum requirement set by metabase as 10.2

Mysql version commands returns me:

mysql --version

mysql Ver 15.1 Distrib 10.3.24-MariaDB, for Linux (x86_64) using readline 5.1

Yes i am using SSH tunnel when connecting to metabase. In the database configuration we have kept the SSH open and provided credentials.

We tried with installing metabase without Docker but it use to get stucked at Memory Initialization stage. So we then installed Metabase using Docker and it worked. The problem is that with docker after a period of idle time the connection breaks and it gives us the error “Socket fail to connect to host:localhost, port:42016. Connection refused (Connection refused)”,

Thanks

Also if this is resolved can you suggest a better way of installing SSL over it

@David_St
Okay, you’re seeing this issue:
https://github.com/metabase/metabase/issues/6114 - upvote by clicking :+1: on the first post
Workaround is to use manual SSH tunnel instead of the built-in SSH tunnel in Metabase, but that’s a lot more difficult inside of a container unless you’ve created your own image.
https://www.metabase.com/docs/latest/administration-guide/01-managing-databases.html#what-if-the-built-in-ssh-tunnels-dont-fit-my-needs

And when not using Docker, then you’re seeing this, because your server is running out of entropy:
https://github.com/metabase/metabase/issues/10175 - workaround is to install haveged

checking

@flamber what you recommend we should go for docker with manual SSH?

So when we connect database we are able to see all the data. Its when after an ideal time we get an issue. I never see a timeout error.

@David_St
The tunnel timeout after idle activity - that’s your problem. You need to create the tunnel manually. It’s up to you if you want to use Docker or JAR, whichever you prefer.

so we need to execute this command

ssh -Nf -L input-port:internal-server-name:port-on-server username@bastion-host.domain.com

Can you give me commands to set metabase tunnel manually, please

@David_St I don’t know your setup or network, so I cannot give you that information. But you need to figure out how to setup a tunnel, which is not related to Metabase, so I would recommend that you search the internet or ask on stackoverflow.com
https://www.digitalocean.com/community/questions/how-to-connect-to-mariadb-using-ssh-tunneling-and-port-forwarding

Thanks Flamber. But any ideas of how to use ssl over metabase that is installed using docker

@David_St If you search the forum you’re find various examples by using a reverse-proxy in front of the Metabase container.
This is not specific to Metabase either - example:
https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose