14

Default port of Keycloak used to be on 8080. Now when I am starting keycloak using

./bin/standalone.sh

then it is getting start on 9990 port. // So I guess now keycloak default port is 9990 nowadays.

but funny part is whenever I am giving explicit keycloak port like below:

 ./bin/standalone.sh  -Djboss.socket.binding.port-offset=8080

after this keycloak is starting on port 17101 . So weird.

I am struggling to start keycloak on 8080 port. How can I do that?

And one more thing :

surprisingly something called as undertow is running on 8080 port. When I am trying to start keycloak, I can trace that in stacktrace:

YUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
Aritz
  • 30,971
  • 16
  • 136
  • 217
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62

5 Answers5

18

If you run basic bin/standalone.sh without changing any configuration, your keycloak server will be started on port 8080.

I believe what confuses you is the log you get when your server starts, more specifically this part:

12:25:25,688 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990

Port 9990 is not your keycloak server, it is WildFly one.

You are also using offset wrong. Basically, offset is the number you increment your original port (8080) for.

If you set offset to 15, your keycloak server will run on port 8095.

Also, before starting keycloak, check if there is any other process using port 8080

lsof -i :8080 
Dino
  • 7,779
  • 12
  • 46
  • 85
16

I changed the http port of keycloak serve (I'm using 19.0.1 version distribution powered by Quarkus) by doing the following steps :

  1. Open : keycloak-folder/conf/keycloak.conf
  2. Set the port number : http-port=8180

Note that you can also set the port number at the command line :

on Linux/Unix:

$ bin/kc.sh start-dev --http-port=8180

on Windows:

$ bin\kc.bat start-dev --http-port=8180
Ousama
  • 2,176
  • 3
  • 21
  • 26
15

The default port is still 8080. Check in standalone/configuration/standalone.xml in the Keycloak installation directory and look for jboss.http.port. If you want to force the port, use -Djboss.http.port=8080. You're using the offset configuration. In your case, because standalone.xml appears to have been changed you're adding 8080 to the base port.

stdunbar
  • 16,263
  • 11
  • 31
  • 53
  • surprisingly something called as undertow is running on 8080 port. When I am trying to start keycloak. YUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080 – Pramod S. Nikam Nov 28 '17 at 04:23
  • - Thanks, I tried -Djboss.http.port=8080 but still its starting on 9990 port. undertow is listening on 8080 – Pramod S. Nikam Nov 28 '17 at 04:26
9
 ./bin/standalone.sh  -Djboss.socket.binding.port-offset=8080

By providing value 8080 for jboss.socket.binding.port-offset, you add "8080" to all portbindings on the server which is wrong.

You can do the following to get rid of your problem.

./standalone.sh -b 0.0.0.0 -Djboss.socket.binding.port-offset=1000

This adds "1000" to all portbindings on the server, which avoids port conflicts.

Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
2

you can also run it by docker instead of installing it. more easy to paste this command in docker-compose file in project and if you want to change port you can do it easly:


version: ‘3’
volumes:
  Postgres_data:
      driver: local
services:
   postgres:
      image: postgres
      volumes:
           - postgres_data:/var/lib/postgresql/data
      ports:
           - 5432:5432
      environment:
           POSTGRES_DB: keycloak
           POSTGRES_USER: keycloak
           POSTGRES_PASSWORD: password
   keycloak:
       image: jboss/keycloak
       environment:
            DB_VENDOR: POSTGRES
            DB_ADDR: postgres
            DB_DATABASE: keycloak
            DB_USER: keycloak
            DB_SCHEMA: public
            DB_PASSWORD: password
            KEYCLOAK_USER: admin
            KEYCLOAK_PASSWORD: admin
            # Uncomment the line below if you want to specify JDBC             parameters. The parameter below is just an example, and it shouldn’t be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it.
            #JDBC_PARAMS: “ssl=true”
       ports:
            - 8080:8080
       depends_on:
            - postgres

fateme ghasemi
  • 243
  • 1
  • 4
  • 9