1

I'm having trouble initializing a database with sequelize in my docker image. I keep getting a connection refused error because of the unix socket since I can't use localhost.

I've read how to create one with a script, but my project uses sequelize.

I've also tried various tactics with socket connections and using socat

psql commands will succeed in my init script, but the yarn command or sequelize commands end up with ERROR: connect ECONNREFUSED 127.0.0.1:5432

My finial init script looks like this:

socat TCP-LISTEN:5432 UNIX-CONNECT:/var/run/postgresql/.s.PGSQL.5432 & yarn --cwd /root db-create

The create command just calls dotenv sequelize db:create

I'm not really sure where to go from here. It seems like this should be a simple thing. Am I just missing something obvious?

-EDIT

It's worth pointing out that this was working fine with a postgres install. It was working fine when we just fired up postgres in the database and run the yarn commands after. The only difference here is we are trying to have the database created and migrated when the container starts so it's not a manual process.

loctrice
  • 2,454
  • 1
  • 23
  • 34

1 Answers1

1

If you bind to localhost you should be able to hit it at 127.0.0.1:5432

socat TCP-LISTEN:5432,bind=127.0.0.1,reuseaddr,fork UNIX-CLIENT:/var/run/postgresql/.s.PGSQL.5432 &
Jimmy P
  • 1,790
  • 4
  • 17
  • 32