Local Keycloak Setup
For local development, Keycloak is configured to use the hostname keycloak like in the RefArch setup instead of localhost.
This is required because:
- Browser redirects on the host must resolve to
127.0.0.1. - PHP code running in containers must resolve via container network DNS.
- Inside containers,
localhostpoints to the container itself.
Add keycloak to hosts macOS/Linux
bash
echo "127.0.0.1 keycloak" | sudo tee -a /etc/hostsAdd keycloak to hosts Windows
Open Notepad as Administrator (right-click -> Run as administrator).
Open
C:\Windows\System32\drivers\etc\hosts.Add this line at the end:
text127.0.0.1 keycloakSave the file.
Restart the Local Environment and Verify:
After adding the entry, restart Keycloak/container stack:
bash
# Podman
podman machine stop && \
podman machine start && \
devcontainer up --workspace-folder .bash
# DDEV
ddev restartVerify:
bash
ping keycloakPodman (Linux) note
Podman may merge host /etc/hosts into containers, which can break in-container keycloak resolution. Add this to ~/.config/containers/containers.conf:
ini
[containers]
base_hosts_file="none"