简体   繁体   中英

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

标题为“错误”和正文“404 - 未找到”的错误页面的屏幕截图

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 .

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

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

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)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM