Unable to connect POSTGRES in Docker


I have stuck for many days on a single startup and have been using the same commands to start the hydra

I can easily run it using DATABASE_URL=memory
but i have to run it using POSTGRES

command for hydra-migrate has been done easily but still I am attaching the snippets of commands which i have used till now.

docker pull oryd/hydra:unstable

docker run --name hydra–postgres -e POSTGRES_USER=hydra -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=hydra -d postgres:9.6

docker run --link hydra–postgres:postgres -it --entrypoint hydra oryd/hydra:unstable migrate sql postgres://hydra:[email protected]:5432/hydra?sslmode=disable

docker run -it --rm --name login-consent-hydra -p 4444:4444 -e OAUTH2_SHARE_ERROR_DEBUG=1 -e LOG_LEVEL=debug -e OAUTH2_CONSENT_URL=http://localhost:3000/consent -e OAUTH2_CONSENT_URL=http://localhost:3000/consent -e OAUTH2_LOGIN_URL=http://localhost:3000/login -e OAUTH2_ISSUER_URL=http://localhost:4444 -e DATABASE_URL=postgres://hydra:[email protected]:5432/hydra?sslmode=disable oryd/hydra:unstable serve --dangerous-force-http

I am stuck on this code for a lot of time

Getting following Error:

Unable to connect to database error=“Could not Connect to SQL: dial tcp connect: connection refused”

Please help as it is urgent


You’re not linking the last image to the database


Use the yml file to start the stack.


Thanks it worked now