# Keycloak needs to restart to create the administrator user with external postgresql

**URL:** <https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213>\
**Category:** Getting advice\
**Tags:** admin-console, database\
**Created:** [November 19, 2021, 1:52pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213 "2021-11-19T13:52:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgarcia](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@cgarcia](https://forum.keycloak.org/u/cgarcia)\
**Post date:** [November 19, 2021, 1:52pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213/1 "2021-11-19T13:52:59Z")

</div>

hi guys im using keycloak from a custom docker [Quay](http://quay.io/keycloak/keycloak:15.0.2) image that i already configured to use an external postgresql database, locally it works fine, but when im deploying it into a dev environment it needs to restart the server to create the administrator user to access the console, does anyone knows how to create the user previously so i dont need to restart the server?? or if there is any way to pre-configure the administrator user??

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [November 19, 2021, 4:58pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213/2 "2021-11-19T16:58:52Z")

</div>

Set the environment variables `KEYCLOAK_USER` and `KEYCLOAK_PASSWORD`.  
See also [keycloak-containers/server at main · keycloak/keycloak-containers · GitHub](https://github.com/keycloak/keycloak-containers/tree/main/server#creating-admin-account)

(Don‘t be confused of `jboss/keycloak` and the `quay.io…` images, [quay.io](http://quay.io) is the origin, it‘s mirrored to docker hub.)

---

<div class="post-metadata">

**Author:** ![cgarcia](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@cgarcia](https://forum.keycloak.org/u/cgarcia)\
**Post date:** [November 19, 2021, 5:58pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213/3 "2021-11-19T17:58:58Z")

</div>

im already using this environment variables for the keycloak container

```
  DB_VENDOR
  DB_ADDR
  DB_DATABASE
  DB_USER
  DB_SCHEMA
  DB_PASSWORD
  KEYCLOAK_USER
  KEYCLOAK_PASSWORD
  KEYCLOAK_STATISTICS

```

and this environment variables for the postgresql container  
POSTGRES\_DB  
POSTGRES\_USER  
POSTGRES\_PASSWORD  
and im using the standalone configuration to run keycloak locally and it works perfectly fine, but when i deploy it to AWS i use the following services  
ECS  
ECR  
Alb  
Ec2  
RDS  
route53  
acm  
network resources (public and private subnets, vpc, internet gateway, nat gateway, eips, route tables)  
and it doesnt work, after thinking a while my guess is that i need to do some configuration for the alb to be able to run along keycloak, i also believe that i need to do some extra configuration to keycloak server to run on domain mode along alb

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [November 19, 2021, 6:35pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213/4 "2021-11-19T18:35:38Z")

</div>

So you started this thread with asking for initial admin user and then throwing all and everything you deal with into the pot and guessing wildly different topics and making assumptions.

I won‘t help.  
Good luck.

---

<div class="post-metadata">

**Author:** ![cgarcia](https://avatars.discourse-cdn.com/v4/letter/c/67e7ee/32.png) [@cgarcia](https://forum.keycloak.org/u/cgarcia)\
**Post date:** [November 19, 2021, 6:57pm UTC](https://forum.keycloak.org/t/keycloak-needs-to-restart-to-create-the-administrator-user-with-external-postgresql/12213/5 "2021-11-19T18:57:19Z")

</div>

Thanks for your time !
