Skip to content
Switch branches/tags
This branch is 61 commits ahead, 1 commit behind mrako/wait-for:master.

Latest commit

Bumps [bats]( from 1.6.0 to 1.7.0.
- [Release notes](
- [Changelog](
- [Commits](bats-core/bats-core@v1.6.0...v1.7.0)

- dependency-name: bats
  dependency-type: direct:development
  update-type: version-update:semver-minor

Signed-off-by: dependabot[bot] <>

Git stats


Failed to load latest commit information.


Wait for another service to become available
GitHub release (latest by date) Script file size
Example usage · Submit a PR

./wait-for is a script designed to synchronize services like docker containers. It is sh and alpine compatible. It was inspired by vishnubob/wait-for-it, but the core has been rewritten at Eficode by dsuni and mrako.

When using this tool, you only need to pick the wait-for file as part of your project.


Download the wait-for file, either the latest from master or for a specific version check out the Releases-page.

With the file locally on your file system, you can directly invoke it.

./wait-for host:port|url [-t timeout] [-- command args]
  -q | --quiet                        Do not output any status messages
  -t TIMEOUT | --timeout=timeout      Timeout in seconds, zero for no timeout
  -v | --version                      Show the version of this tool
  -- COMMAND ARGS                     Execute command with args after the test finishes

Alternatively, you could download the script and pipe it into sh:

$ wget -qO- | sh -s -- -- echo success

Note: When using the latter option, make sure to pin the version by commit hash. Future releases could introduce non-backwards compatible changes and leaves you vulnerable to malicious users modifying this script in the future (as has e.g. happened with Codecov).


To check if is available:

$ ./wait-for -- echo "Eficode site is up"
Eficode site is up

To wait for database container to become available:

version: "3"

    image: postgres:9.4

    build: backend
    command: sh -c './wait-for db:5432 -- npm start'
      - db

To check if is available over HTTPS:

$ ./wait-for -- echo "Eficode is accessible over HTTPS"
Eficode is accessible over HTTPS

To wait for your API service to become available:

version: "3"

    image: nginx

    build: .
    command: sh -c './wait-for http://api -- echo "The api is up! Let's use it"'
      - api


Ironically testing is done using bats, which on the other hand is depending on bash.

docker build -t wait-for .
docker run --rm -t wait-for


When creating PRs, please style your commit messages according to conventional commit, you can use a tool like commitizen to guide you. We will automatically infer the changelog from your commits. Alternatively, we can squash all commits when merging and update the commit message.

This project strongly prefers maintaining backwards compatibility, therefore some obvious "fixes" might not be accepted.

Also, please include or update the test cases whenever possible by extending wait-for.bats.


Make sure netcat is installed in your Dockerfile before running the command if you test over plain TCP.

RUN apt-get -q update && apt-get -qy install netcat

If you are connecting over HTTP, then you will need to have wget available.