# KeyCloak redirect\_uri gives 404 page not found error

**URL:** <https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892>\
**Category:** Kibana\
**Tags:** elastic-stack-security\
**Created:** [October 5, 2022, 2:57pm UTC](https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892 "2022-10-05T14:57:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssimmons](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@ssimmons](https://discuss.elastic.co/u/ssimmons)\
**Post date:** [October 5, 2022, 2:57pm UTC](https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892/1 "2022-10-05T14:57:21Z")

</div>

I'm using Elasticsearch and Kibana 7.16.3. I've gotten SSL/TLS properly setup on my local install. I've gotten KeyCloak set up and working. I can bring up Kibana and login with Keycloak successfully. However, after login, Kibana redirects me to the following URL: `https://localhost:5601/api/security/oidc/callback?state=X7lczvuWbZ1fJuA3y3Nq1vcf0H0I8vLSIbSGl1D9M-c&session_state=38edf960-3d80-4566-80c4-69eb11c57cba&code=9fcfe101-9117-46d8-b72f-bb34ca7e2851.38edf960-3d80-4566-80c4-69eb11c57cba.6213f326-ae59-46d3-9280-9b0608cfb650`  
This returns a page that reads "Not Found". So the redirect after logging in with Kibana doesn't seem to be working properly. I've set my Valid Redirect URIs in KeyCloak as `https://localhost:5601/*`. I'm not getting any error messages from Elasticsearch or Kibana.

I am running Elasticsearch and Kibana through Docker.

---

<div class="post-metadata">

**Author:** ![ssimmons](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@ssimmons](https://discuss.elastic.co/u/ssimmons)\
**Post date:** [October 5, 2022, 8:51pm UTC](https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892/2 "2022-10-05T20:51:41Z")

</div>

I figured out my issue. I didn't have the `server.basePath` parameter set in the `kibana.yml` file so when it started up, it used the random three letters as the base URL. Since my `redirect_uri` didn't include those three letters, it was an invalid request. Once I set the `server.basePath` and included that in my `redirect_uri`, the redirect worked properly.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 6, 2022, 12:53am UTC](https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892/3 "2022-10-06T00:53:41Z")

</div>

Thanks for sharing your solution!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 3, 2022, 12:54am UTC](https://discuss.elastic.co/t/keycloak-redirect-uri-gives-404-page-not-found-error/315892/4 "2022-11-03T00:54:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
