Socket fail to connect to host:localhost, port:34819. Connection refused (Connection refused)

Hi,

I have upgraded to the latest version 0.38.2 on AWS Elastic beanstalk and the latest docker. After getting upgraded everything is working fine, but my main database which is on MySQL Amazon RDS is having problem and giving me the below error

Socket fail to connect to host:localhost, port:34819. Connection refused (Connection refused)

The major this is that, once I save the database connection, it work fines for few minutes, but after few minutes, if try to retrieve any data, it gives the above error message. After saving the database connection again, it starts working for some time and then stops.

Let me know, how to get this issue resolved and also would like to know, can I roll back to old version, as this my production server.

{
  "browser-info": {
    "language": "en-US",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.10+9",
    "java.vendor": "AdoptOpenJDK",
    "java.vendor.url": "https://adoptopenjdk.net/",
    "java.version": "11.0.10",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.10+9",
    "os.name": "Linux",
    "os.version": "4.14.219-119.340.amzn1.x86_64",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "mongo",
      "mysql",
      "googleanalytics",
      "h2"
    ],
    "hosting-env": "elastic-beanstalk",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "10.15"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.18"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2021-03-17",
      "tag": "v0.38.2",
      "branch": "release-x.38.x",
      "hash": "91f0ed6"
    },
    "settings": {
      "report-timezone": "Asia/Calcutta"
    }
  }
}

Hi, are you using an ssh tunnel to connect to your rds database?

Yes. I am having a SSH tunnel to connect with my RDS.

But the strange thing is, if i save the database connection, it works fine for few minutes. This strange this has started after the upgrade to the latest version.

And every time, I see the error, a new port number is shown in the message.

@amitkumar The issue has been fixed in the upcoming 0.39.0 (release in a few weeks)
https://github.com/metabase/metabase/issues/10081
The only workarounds are to connect directly, or setup the tunnel manually outside of Metabase instead of using the built-in tunnel (but that isn't possible/easy on EB)
https://www.metabase.com/docs/latest/administration-guide/01-managing-databases.html#what-if-the-built-in-ssh-tunnels-dont-fit-my-needs

Then do we have an option to roll back to the older version, back to 0.34.3 (on which I was earlier).

@amitkumar I would recommend that you revert to your backup. Metabase does not officially support downgrading, but you can try by using a configuration script for the version you want to revert to:
https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-elastic-beanstalk.html#deploying-new-versions-of-metabase-on-elastic-beanstalk