How to start keycloak 2.0 on 8080 port?

28,889

Solution 1

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 

Solution 2

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.

Solution 3

 ./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.

Solution 4

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

Share:
28,889
Pramod S. Nikam
Author by

Pramod S. Nikam

Lets make tools Open Source! Do visit http://www.techprehension.com AlwaysReadyToHelp

Updated on July 19, 2022

Comments

  • Pramod S. Nikam
    Pramod S. Nikam almost 2 years

    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