Wait4X allows you to wait for a port or a service to enter the requested state.
Wait4X allows you to wait for a port or a service to enter the requested state.
Wait4X helps you wait for services (databases, APIs, message queues, etc.) to be ready before your app or script continues. It's ideal for:
| Feature | Description |
|---|---|
| Multi-Protocol | TCP, HTTP, DNS, and more |
| Service Integrations | Redis, MySQL, PostgreSQL, MongoDB, Kafka, RabbitMQ, InfluxDB, Temporal |
| Reverse/Parallel Checking | Invert checks or check multiple services at once |
| Exponential Backoff | Smarter retries |
| Cross-Platform | Single binary for Linux, macOS, Windows |
| Go Package | Use as a Go library |
| Command Execution | Run commands after checks |
After installing, jump to Quick Start to try it out!
With DockerWait4X provides automatically updated Docker images within Docker Hub:
# Pull the image
docker pull wait4x/wait4x:latest
# Run the container
docker run --rm wait4x/wait4x:latest --helpmacOS:
brew install wait4xAlpine Linux:
apk add wait4xArch Linux (AUR):
yay -S wait4x-binNixOS:
nix-env -iA nixpkgs.wait4xWindows (Scoop):
scoop install wait4xDownload the appropriate version for your platform from the releases page:
Linux:
curl -LO https://github.com/wait4x/wait4x/releases/latest/download/wait4x-linux-amd64.tar.gz
tar -xf wait4x-linux-amd64.tar.gz -C /tmp
sudo mv /tmp/wait4x-linux-amd64/wait4x /usr/local/bin/macOS:
curl -LO https://github.com/wait4x/wait4x/releases/latest/download/wait4x-darwin-amd64.tar.gz
tar -xf wait4x-darwin-amd64.tar.gz -C /tmp
sudo mv /tmp/wait4x-darwin-amd64/wait4x /usr/local/bin/Windows:
curl -LO https://github.com/wait4x/wait4x/releases/latest/download/wait4x-windows-amd64.tar.gz
tar -xf wait4x-windows-amd64.tar.gz
# Move to a directory in your PATHVerify checksums:
curl -LO https://github.com/wait4x/wait4x/releases/latest/download/wait4x-linux-amd64.tar.gz.sha256sum
sha256sum --check wait4x-linux-amd64.tar.gz.sha256sumYou can install Wait4X directly from source using Go (requires Go 1.16+):
go install wait4x.dev/v3/cmd/wait4x@latestThis will place the wait4x binary in your $GOPATH/bin or $HOME/go/bin directory.
Get started in seconds! After installing, try these common checks:
wait4x tcp localhost:3306wait4x http https://example.com/health --expect-status-code 200wait4x tcp 127.0.0.1:5432 127.0.0.1:6379 127.0.0.1:27017wait4x postgresql 'postgres://user:pass@localhost:5432/mydb?sslmode=disable'For more, see Usage Examples or Detailed Usage.
Here are some of the most useful Wait4X commands. Click the links for more details!
wait4x tcp localhost:8080wait4x http https://api.example.com/health --expect-status-code 200 --expect-body-regex '"status":"UP"'wait4x dns A example.comwait4x mysql 'user:password@tcp(localhost:3306)/mydb'wait4x redis redis://localhost:6379 --expect-key "session:active"wait4x tcp localhost:8080 -- ./start-app.shwait4x tcp localhost:8080 --invert-checkwait4x tcp localhost:3306 localhost:6379 localhost:27017See Detailed Usage for advanced options and more protocols.
Jump to:
Wait for an HTTP(S) endpoint to be ready, with flexible validation options.
wait4x http https://api.example.com/health --expect-status-code 200wait4x http https://api.example.com/status --expect-body-regex '"status":\s*"healthy"'wait4x http https://api.example.com/status --expect-body-json "services.database.status"wait4x http https://example.com --expect-body-xpath "//div[@id='status']"wait4x http https://api.example.com \
--request-header "Authorization: Bearer token123" \
--request-header "Content-Type: application/json"wait4x http https://api.example.com --expect-header "Content-Type=application/json"wait4x http https://www.wait4x.dev --cert-file /path/to/certfile --key-file /path/to/keyfile
wait4x http https://www.wait4x.dev --ca-file /path/to/cafileCheck for various DNS record types and values.
wait4x dns A example.com
wait4x dns A example.com --expected-ip 93.184.216.34
wait4x dns A example.com --expected-ip 93.184.216.34 -n 8.8.8.8wait4x dns AAAA example.com --expected-ip "2606:2800:220:1:248:1893:25c8:1946"wait4x dns CNAME www.example.com --expected-domain example.comwait4x dns MX example.com --expected-domain "mail.example.com"wait4x dns NS example.com --expected-nameserver "ns1.example.com"wait4x dns TXT example.com --expected-value "v=spf1 include:_spf.example.com ~all"Check readiness for popular databases.
wait4x mysql 'user:password@tcp(localhost:3306)/mydb'wait4x mysql 'user:password@unix(/var/run/mysqld/mysqld.sock)/mydb'wait4x mysql 'user:password@tcp(localhost:3306)/mydb' --expect-table my_tablewait4x postgresql 'postgres://user:password@localhost:5432/mydb?sslmode=disable'wait4x postgresql 'postgres://user:password@/mydb?host=/var/run/postgresql'wait4x postgresql 'postgres://user:password@localhost:5432/mydb?sslmode=disable' --expect-table my_tablecurrentSchema=myschema connection string parameter, for example:wait4x postgresql 'postgres://user:password@localhost:5432/mydb?sslmode=disable¤tSchema=myschema' --expect-table my_tablewait4x mongodb 'mongodb://user:password@localhost:27017/mydb?maxPoolSize=20'wait4x redis redis://localhost:6379wait4x redis redis://user:password@localhost:6379/0wait4x redis redis://localhost:6379 --expect-key "session:active"wait4x redis redis://localhost:6379 --expect-key "status=^ready$"wait4x influxdb http://localhost:8086wait4x rabbitmq 'amqp://guest:guest@localhost:5672/myvhost'wait4x temporal server localhost:7233wait4x temporal worker localhost:7233 \
--namespace my-namespace \
--task-queue my-queuewait4x temporal worker localhost:7233 \
--namespace my-namespace \
--task-queue my-queue \
--expect-worker-identity-regex "worker-.*"Basic Kafka broker readiness check:
wait4x kafka kafka://localhost:9092Check Kafka broker with SCRAM authentication:
wait4x kafka kafka://user:pass@localhost:9092?authMechanism=scram-sha-256Wait for multiple Kafka brokers (cluster) to be ready:
wait4x kafka kafka://broker1:9092 kafka://broker2:9092 kafka://broker3:9092Notes:
- The connection string format is: kafka://[user:pass@]host:port[?option=value&...]
- Supported options: authMechanism (scram-sha-256, scram-sha-512)
Wait for a shell command to succeed or return a specific exit code.
wait4x exec 'ping wait4x.dev -c 2'wait4x exec 'ls target/debug/main' --exit-code 2See Advanced Features for timeout, retry, backoff, and parallel/reverse checking options.
Jump to:
Control how long Wait4X waits and how often it checks.
Set a timeout:
wait4x tcp localhost:8080 --timeout 30sWaits up to 30 seconds before giving up.
Set check interval:
wait4x tcp localhost:8080 --interval 2sChecks every 2 seconds (default: 1s).
Retry with increasing delays for more efficient waiting (useful for slow-starting services).
wait4x http https://api.example.com \
--backoff-policy exponential \
--backoff-exponential-coefficient 2.0 \
--backoff-exponential-max-interval 30sWait for a service to become unavailable (e.g., port to be free, service to stop).
No open issues yet, or sync has not completed.