-1

I am using podman to host and run mysql server. I have defined and created a container using the following terminal command:

podman run --name techBlog -e MYSQL_ROOT_PASSWORD='my-password' -e MYSQL_DATABASE='blog_db' -d mysql:latest

but when I attempt to run my server.js script it returns:

  original: Error: connect ECONNREFUSED ::1:3306
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
    errno: -4078,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '::1',
    port: 3306,
    fatal: true
  }

I have made sure that my database name, password, and port are correct. The code worked when I has mysql hard installed and I am am unsure why it does not work anymore with podman hosting.

I expected upon creation of the podman container that I would be able to run my server.js file and connect to the mysql server.

S-coding
  • 1
  • 2
  • 2
    SQL Server and MySQL are completely different products, and you're clearly mixing them up. Not sure if that's your issue, but please fix your question at least so that it only uses the correct names. – James Z Apr 16 '23 at 18:34
  • Connection refused means that either there is no mysql running on the target host or it listens on another port. – Shadow Apr 16 '23 at 20:13
  • The [__--publish_](https://docs.podman.io/en/latest/markdown/podman-run.1.html#publish-p-ip-hostport-containerport-protocol) command-line option is missing. – Erik Sjölund Apr 17 '23 at 16:54

1 Answers1

0

I ended up finding the answer. The error ::1:3306 meant for some reason MySQL was having a hard time connecting to my local server which I had defined in my connection.js file. By changing “localhost” to “127.0.0.1” (the loop back address) I got the connection to work. Still not 100% sure why it was having a hard time before but the new loop around method work fine.

S-coding
  • 1
  • 2