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:

[“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)”
“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.

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)”,


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

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.

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


@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.

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

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: