# Connect postgresql failed in docker

**URL:** <https://discuss.konghq.com/t/connect-postgresql-failed-in-docker/5055>\
**Category:** Questions\
**Created:** [December 3, 2019, 7:01am UTC](https://discuss.konghq.com/t/connect-postgresql-failed-in-docker/5055 "2019-12-03T07:01:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vsuns](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@vsuns](https://discuss.konghq.com/u/vsuns)\
**Post date:** [December 3, 2019, 7:01am UTC](https://discuss.konghq.com/t/connect-postgresql-failed-in-docker/5055/1 "2019-12-03T07:01:32Z")

</div>

I am fresh for docker and kong .

I have 2 ECS instances just call them “A” and “B” ;  
I install docker and build kong 1.3 on “A” ;  
The “B” has a postgressql ;  
The I try to migrations kong on “A” linking to postgresql on “B”, like:

docker run --rm  
-e “KONG\_DATABASE=postgres”  
-e “KONG\_PG\_HOST=10.47.136.45”  
-e “KONG\_PG\_PORT=6506”  
-e “KONG\_PG\_DATABASE=devauth”  
-e “KONG\_PG\_USER=devauthdata”  
-e “KONG\_PG\_PASSWORD=Paic1234#”  
ay/kong:1.3 kong migrations bootstrap

it failed :  
Error: [PostgreSQL error] failed to retrieve server\_version\_num: FATAL: password authentication failed for user “devauthdata”

but the username and password are valid ！！！

=-------------------------------------------

I think I know that:  
it is Special characters !  
the password contains a “#” !  
I just try a new password without “#” , it success !!!  
so, is the way for kong to link postgresql-11 wrong???  
or need some improvement？

---

<div class="post-metadata">

**Author:** ![vsuns](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@vsuns](https://discuss.konghq.com/u/vsuns)\
**Post date:** [December 5, 2019, 12:26am UTC](https://discuss.konghq.com/t/connect-postgresql-failed-in-docker/5055/2 "2019-12-05T00:26:36Z")

</div>

i try 1.4.1 and it works well !

---

<div class="post-metadata">

**Author:** ![sjweixel](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@sjweixel](https://discuss.konghq.com/u/sjweixel)\
**Post date:** [September 9, 2020, 9:16pm UTC](https://discuss.konghq.com/t/connect-postgresql-failed-in-docker/5055/3 "2020-09-09T21:16:15Z")

</div>

The # in postgres password seems to still be an issue. I’m using docker secrets to set the postrges password and setting KONG\_PG\_PASSWORD\_FILE. I’ve noticed when the docker secret value contains a #, “kong start” will exist with an error. Strangely the kong bootstrap/up/list/finish seem work without issue when the secret contains a #. I’ve tried this on 2.0.5 and 2.1.3.

nginx: [warn] load balancing method redefined in /usr/local/kong/nginx-kong.conf:56  
2020/09/09 20:45:14 [error] 33#0: init\_by\_lua error: /usr/local/share/lua/5.1/kong/init.lua:447: [PostgreSQL error] failed to retrieve PostgreSQL server\_version\_num: FATAL: password authentication failed for user “kong”  
stack traceback:  
[C]: in function ‘assert’  
/usr/local/share/lua/5.1/kong/init.lua:447: in function ‘init’  
init\_by\_lua:3: in main chunk  
nginx: [error] init\_by\_lua error: /usr/local/share/lua/5.1/kong/init.lua:447: [PostgreSQL error] failed to retrieve PostgreSQL server\_version\_num: FATAL: password authentication failed for user “kong”  
stack traceback:  
[C]: in function ‘assert’  
/usr/local/share/lua/5.1/kong/init.lua:447: in function ‘init’  
init\_by\_lua:3: in main chunk  
Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: failed to start nginx (exit code: 1)

Run with --v (verbose) or --vv (debug) for more details
