NidhinRaj
NidhinRaj

Reputation: 385

Keycloak returns "404 - Not Found" page

I am trying to install Keycloak on my PC. I have the Java 8 JDK installed.

After running \bin\standalone.bat, when I go to the page 127.0.0.1:9990/auth, I am returned the error

404 - Not Found

screenshot of error page with title "Error" and body "404 - Not Found"

Upvotes: 10

Views: 38601

Answers (8)

ilyesAj
ilyesAj

Reputation: 524

update 2023: the official docker image quay.io/keycloak/keycloak does not automatically points to admin console ( redirects you to / then /auth which gives you 404 not found)if you want to access to admin console go directly to /admin instead

reference: https://www.keycloak.org/getting-started/getting-started-docker

Upvotes: 3

Galilo Galilo
Galilo Galilo

Reputation: 569

In my case it worked fine when I added --http-relative-path=/auth to the run command, thus my docker-compose file is:

version: '3.8'
services:
  keycloak:
    image: quay.io/keycloak/keycloak:19.0.1
    command: ['start-dev --import-realm --http-relative-path=/auth']
    volumes:
      - ./realm-config:/opt/keycloak/data/import
    environment:
      - KC_DB=dev-file
      - KEYCLOAK_ADMIN=administrator
      - KEYCLOAK_ADMIN_PASSWORD=not-my-password
      - KC_FEATURES=scripts
      - KC_HTTP_PORT=9080
      - KC_HTTPS_PORT=9443
    ports:
      - 127.0.0.1:9080:9080
      - 127.0.0.1:9443:9443

Upvotes: 1

Peter
Peter

Reputation: 3407

In my case the docs I read didn't mention to edit the <default-bindings .... datasource=... when adding a database. The server.log showed the wrong datasource name 'ExampleDS' which made it clear enough:

2021-11-15 18:32:29,302 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "keycloak-server.war")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.datasources.ExampleDS"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.auth.auth.DefaultDataSource is missing [jboss.naming.context.java.jboss.datasources.ExampleDS]"]
}

So I fixed that...and was failing to connect to the database, because my database wasn't listening on the address it used.

Caused by: org.postgresql.util.PSQLException: Connection to <host_goes_here>:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Reconfiguring PostgreSQL fixed that:

/etc/postgresql/12/main/postgresql.conf

listen_addresses = '*'

/etc/postgresql/12/main/pg_hba.conf

host    keycloak    keycloak     <ip_goes_here>/32    <method_goes_here>

And FYI other than looking at config, you can use things like this to see what it listens to:

lsof -Pni | grep java
ss -ltp | grep java
netstat -lantp | grep java

Upvotes: -1

Abhay
Abhay

Reputation: 526

I was facing this issue with Keycloak running on Ubuntu image inside Docker. What worked for me was adding -b 0.0.0.0 argument.

So one can try running following command: bin/standalone.sh -b 0.0.0.0

You may be able to access console at localhost:8080

Upvotes: 0

Barthy
Barthy

Reputation: 3231

I had set a "Frontend URL" (Keycloak Admin Console > Realm Settings > General Frontend Url) for the realm that looked like this: http://localhost:8080 while the client's "Root URL" was http://localhost:8080/auth.

After removing the "Frontend URL" everything worked fine. Another solution was to set both fields to http://localhost:8080/auth.

Upvotes: 7

user15979436
user15979436

Reputation: 1

I had the same problem and then noticed that when I started standalone .bac, at the beginning of the prompt it said something like "JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.", then if is that the case, just delete the JBOSS_HOME environment variable. I solved in this way. (I don't know how good is this solution, but i had no other ways to make it works)

Upvotes: 0

Subodh Joshi
Subodh Joshi

Reputation: 13492

If you will check keycloak documentation you will get detail information about port that you can modify as well only condition that port should not capture by any other application.

 <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>

So default port http its 8080 and https its 8443

Upvotes: -1

Boomer
Boomer

Reputation: 3711

The correct port for Keycloak is 8080. The 9990 is the port for Wildfly administration.
Use http://localhost:8080/auth

Upvotes: 6

Related Questions