Yaws webserver
Erlang Shell C JavaScript Makefile M4 Other
Latest commit ca5b0b8 Dec 12, 2016 @weisslj weisslj committed with capflam Improve finding of private ports
Since df1d7bf Yaws does not really open port 0 anymore, but tries to
open one from 49152 onwards. This leads to "badbind" errors when e.g.
executing multiple separate common test runs which use Yaws repeatedly.

With this patch port 0 is opened instead, the port number retrieved, and
closed again. This still is not completely safe, as the port could be
taken by another application in the short time Yaws tries to listen on
it again, but in practice I could not reproduce badbind errors.

This approach leaves all advantages of df1d7bf, but also respects the
local range for dynamic ports if specified, see

Here is a test program which illustrates the problem. With this patch
it runs continuously, without it stops with "badbind":



    trap "exit" INT TERM
    trap "kill 0" EXIT

    sim_testcase () {
        echo "ct run $1, testcase $2"
        output=`erl -pa ebin -noshell \
            -eval 'yaws:start_embedded("www/testdir", [{port, 0}], [], "'$1'")' \
            -eval 'timer:sleep(1000)' \
            -eval 'yaws:stop()' \
            -eval 'init:stop()' \
        if [[ $retval -ne 0 ]] ; then
            case $output in
                *badbind*) echo "---> BADBIND <---" ;;
                *) echo "$output" ;;
        return $retval

    sim_ct_run () {
        if sim_testcase $1 $n ; then
            sim_ct_run $1 $n
            kill 0

    set -m
        for tag in `seq 1 $NUM_CT_CONCURRENT` ; do
            sim_ct_run $tag 0 &
Failed to load latest commit information.
applications Remove dynamic wrapper on rand_bytes/1 function Nov 18, 2016
c_src add check for have_sendfile Aug 23, 2015
contrib Use binary:compile_pattern for multipart messages Oct 3, 2015
doc Add support for salted hashes in users credentials Sep 20, 2016
ebin Massive autotools refactoring & cleanup Jul 7, 2014
examples Add yaws_api:websocket_send for ws_state records May 7, 2016
include Add support of unicode characters in the configuration file Oct 30, 2016
m4 Massive autotools refactoring & cleanup Jul 7, 2014
man Add support of unicode characters in the configuration file Oct 30, 2016
munin README.munin Jun 12, 2009
priv Massive autotools refactoring & cleanup Jul 7, 2014
rebar-templates Remove very old use_old_ssl directive Apr 13, 2016
rel Exclude hipe application in reltool.config Sep 10, 2014
scripts Add scripts/systemd directory in the dist files Nov 24, 2016
src Improve finding of private ports Jan 31, 2017
ssl Add SNI support Apr 13, 2016
testsuite Get the port number from the Host header in yaws_api:request_url/1 Jan 31, 2017
win32 Use id to build the command line in the windows startup script Apr 13, 2016
www Remove support for Erlang/OTP R14 and R15 releases Sep 20, 2016
.gitignore Refactor the testsuite to use common_test instead of a in-house frame… Sep 2, 2016
.travis.yml Add Erlang/OTP 19.2 support in .travis.yml Jan 31, 2017
ChangeLog whitespace cleanup Oct 31, 2011
LICENSE whitespace cleanup Oct 31, 2011
Makefile.am Be sure to call the right dialyzer to built the plt file Nov 18, 2016
README.cygwin Massive autotools refactoring & cleanup Jul 7, 2014
README.md Remove support for Erlang/OTP R14 and R15 releases Sep 20, 2016
README.osx Add README.osx for instructions on installing on OSX using Homebrew Oct 7, 2013
README.pkg-config whitespace cleanup Oct 31, 2011
_build.cfg Adding files for Erlware. A very rough packaging of 1.76 has been rel… May 15, 2008
configure.ac Be sure to call the right dialyzer to built the plt file Nov 18, 2016
erlang_deps.mk Refactor the testsuite to use common_test instead of a in-house frame… Sep 2, 2016
include.mk Move Erlang compatibily checks from the configure to a module Apr 13, 2016
known_dialyzer_warnings Update known dialyzer warning Nov 18, 2016
rebar.config Remove support for Erlang/OTP R14 and R15 releases Sep 20, 2016
rebar.config.script Refactor the testsuite to use common_test instead of a in-house frame… Sep 2, 2016
two-mode-mode.el updates to make two-mode-mode work with emacs 23 May 31, 2010
vsn.mk Preparing for 2.0.4 Sep 22, 2016
yaws.pc.in add pkg-config support contributed by Olivier Girondel Jan 29, 2009


This is Yaws, a webserver for dynamic content written in Erlang.

Travis build Status

Prepare build

Get and install an Erlang system (http://www.erlang.org).

To compile Yaws, Erlang/OTP R16B01 or higher is required.

If you've cloned the source from github and you want to build using autotools, note there is no ./configure script in the source, so create one:

$> autoreconf -fi

Install build dependencies. Required packages to compile Yaws are (based on debian packages):

  • build-essential
  • autoconf/automake/libtool
  • erlang - Required apps:
    • erlang-{kernel/stdlib/sasl/erts}
    • erlang-compiler
    • erlang-crypto
    • erlang-xmerl
  • libpam0g-dev

To build the documentation (optional), you also need to install:

  • texlive-latex-base
  • texlive-latex-recommended
  • texlive-fonts-recommended
  • texlive-font-utils
  • texlive-extra-utils
  • ghostscript

On Ubuntu/debian this is pretty much equal to:

$> apt-get build-dep yaws

Finally, to run the testsuites, yaws need to install:

  • git
  • wget
  • curl
  • erlang-eunit
  • erlang-inets
  • erlang-mnesia
  • erlang-ssl
  • cadaver


You can build using rebar:

$> rebar get-deps compile

or via autotools:

$> ./configure --prefix=/usr/local

If using rebar, you'll get a "local installation" with Yaws script in ./bin and the Yaws configuration file in ./etc/yaws.

If using autotools, the build will be configured by default for installation under /usr/local. For more information about installation directories and other supported options, see the configure help. Useful options are:

--with-defaultcharset=CHARSET specify default charset, i.e UTF-8
--with-extrainclude=DIR       dir to include if e.g. pam is installed in some odd place
--with-erlang=PREFIX          prefix where Erlang is installed (optional)

Note to packagers (rpm, deb ...) All install targets support the DESTDIR variable. Thus, if we do

$> ./configure --prefix=/usr; make

we can subsequently do:

$> make install DESTDIR=/foo/bar

All Yaws files will be installed under DESTDIR, but all code will assume Yaws should be installed under /usr.

Main make targets:

  • all : compile Yaws
  • debug : compile Yaws with debug flags
  • clean : remove files produced by all or debug target
  • install : do a proper install of Yaws
  • doc or docs : build the documentation
  • check or test : launch tests
  • cleantest : remove files produced by check target
  • dialyzer : run dialyzer on Yaws
  • mkinstaller : build an installer for windows
  • cleaninstaller: remove files produced by mkinstaller target
  • apps : compile Yaws applications (chat,mail,wiki,yapp)
  • cleanapps : remove files produced by apps target
  • installapps : install Yaws applications
  • fullinstall : install + installapps
  • fullclean : clean + cleantest + cleanapps + cleaninstaller

Test your build

With autotools, to test the build, you should install it somewhere:

$> ./configure --prefix=$PWD/_inst && make install
$> $PWD/_inst/bin/yaws -i

If you used rebar to compile Yaws, you can alternatively start Yaws with

$> ./bin/yaws -i

Either approach will start a webserver at Terminate through ^C, or ^G followed by q, or

> init:stop()

NOTE: If you've used rebar to build the system, none of the following directions apply. With rebar only "local installations" are supported.

Install and run

NOTE: following commands may require root privileges, depending of the installation prefix.

Just run:

$> make install

Then, to run Yaws, you should use its script:

$> ${bindir}/yaws -i

This starts an interactive system.

With the default yaws.conf file, this will create a webserver at http://${host} and one at https://${host}.

You can adapt Yaws configuration by editing '${sysconfig}/yaws/yaws.conf'.

Daemonize Yaws

Start it using '--daemon' and '--heart' options:

$> ${bindir}/yaws --daemon --heart

This will start a daemon (--daemon) which will be autorestarted when/if it crashes or hangs (--heart). Also, for most unices, we create proper start scripts in ${sysconfdir}/init.d

Example: Here is how I compile/start the yaws system that runs at http://yaws.hyber.org (Ubuntu server system)

$> autoreconf -fi
$> ./configure --sysconfdir=/etc
$> make && make install
$> /etc/init.d/yaws start