0

I have installed an instance of parse-server with docker. I have my DB on the Host, but when I run the docker, it says error on connecting to the DB.

docker run -t -d --name parse-server parseplatform/parse-server --appName appname --appId appid--masterKey masterkey --clientKey clientkey --databaseURI postgres://example:1234563@localhost/parse-server --serverURL http://sync.example.com:1337/parse --verbose --publicServerURL http://sync.example.com

And I am getting this error:

Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432
}

I tried with --network host but parse-server is giving me {"error":"unauthorized"} using this docker.

I tried also using -o 5432:5432, but it said the port is used, because the instance running on the host.

How can I connect to the PostgreSQL on the host from the docker parse-server without using --network host?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

1

The problem is that 127.0.0.1 is not your host localhost address, but docker localhost's.

So, you have different options, but maybe It's better trying to connect parse-server to your host address connected with docker network: 172.17.0.X.

Execute ifconfig in your host and see what's your IP address for docker network, and then, try to put it in your command:

docker run -t -d --name parse-server parseplatform/parse-server --appName appname --appId appid--masterKey masterkey --clientKey clientkey --databaseURI postgres://example:1234563@YOUR_HOST_IP_IN_DOCKER_INTERFACE/parse-server --serverURL http://sync.example.com:1337/parse --verbose --publicServerURL http://sync.example.com

You can have a look to Setup a docker container to work with local database

Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42