ranch:stop_listener - Stop a listener


stop_listener(Ref :: ranch_ref())
    -> ok | {error, not_found}

Stop a listener.

The listener is stopped gracefully, first by closing the listening port, then by stopping the connection processes. These processes are stopped according to the shutdown transport option, which may be set to brutally kill all connection processes or give them some time to stop properly.

In order for the connection processes to exit gracefully, they need to trap exit signals and stop before the configured shutdown timeout. If greater control over the shutdown is required the functions ranch:suspend_listener(3) and ranch:wait_for_connections(3) can be used.

This function does not return until the listener is completely stopped.



The listener name.

Return value

The atom ok is returned on success.

An error tuple is returned when the listener is not found.


Stop a listener
ok = ranch:stop_listener(example).

See also

ranch:start_listener(3), ranch:child_spec(3), ranch:suspend_listener(3), ranch(3)

Ranch 1.7 Function Reference


Version select

Like my work? Donate!

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.