class uwsgiconf.options.networking.Networking(*args, **kwargs)

Networking related stuff. Socket definition, binding and tuning.

class sockets

Available socket types to use with .register_socket().


alias of uwsgiconf.options.networking_sockets.SocketDefault


alias of uwsgiconf.options.networking_sockets.SocketFastcgi


alias of uwsgiconf.options.networking_sockets.SocketHttp


alias of uwsgiconf.options.networking_sockets.SocketHttps


alias of uwsgiconf.options.networking_sockets.SocketRaw


alias of uwsgiconf.options.networking_sockets.SocketScgi


alias of uwsgiconf.options.networking_sockets.SocketShared


alias of uwsgiconf.options.networking_sockets.SocketUdp


alias of uwsgiconf.options.networking_sockets.SocketUwsgi


alias of uwsgiconf.options.networking_sockets.SocketUwsgis


alias of uwsgiconf.options.networking_sockets.SocketZeromq

classmethod from_dsn(dsn, *, allow_shared_sockets=None) → uwsgiconf.options.networking_sockets.Socket

Constructs socket configuration object from DSN.


This will also automatically use shared sockets to bind to priviledged ports when non root.


:rtype Socket

set_basic_params(*, queue_size=None, freebind=None, default_socket_type=None)
  • queue_size (int) –

    Also known as a backlog. Every socket has an associated queue where request will be put waiting for a process to became ready to accept them. When this queue is full, requests will be rejected.

    Default: 100 (an average value chosen by the maximum value allowed by default by your kernel).


    The maximum value is system/kernel dependent. Before increasing it you may need to increase your kernel limit too.

  • freebind (bool) –

    Put socket in freebind mode. Allows binding to non-existent network addresses.


    Linux only.

  • default_socket_type (str) – Force the socket type as default. See .socket_types.
set_socket_params(*, send_timeout=None, keep_alive=None, no_defer_accept=None, buffer_send=None, buffer_receive=None)

Sets common socket params.

  • send_timeout (int) – Send (write) timeout in seconds.
  • keep_alive (bool) – Enable TCP KEEPALIVEs.
  • no_defer_accept (bool) – Disable deferred accept() on sockets by default (where available) uWSGI will defer the accept() of requests until some data is sent by the client (this is a security/performance measure). If you want to disable this feature for some reason, specify this option.
  • buffer_send (int) – Set SO_SNDBUF (bytes).
  • buffer_receive (int) – Set SO_RCVBUF (bytes).
set_unix_socket_params(*, abstract=None, permissions=None, owner=None, umask=None)

Sets Unix-socket related params.

  • abstract (bool) – Force UNIX socket into abstract mode (Linux only).
  • permissions (str) –

    UNIX sockets are filesystem objects that obey UNIX permissions like any other filesystem object.

    You can set the UNIX sockets’ permissions with this option if your webserver would otherwise have no access to the uWSGI socket. When used without a parameter, the permissions will be set to 666. Otherwise the specified chmod value will be used.

  • owner (str) – Chown UNIX sockets.
  • umask (str) – Set UNIX socket umask.
set_bsd_socket_params(*, port_reuse=None)

Sets BSD-sockets related params.

Parameters:port_reuse (bool) – Enable REUSE_PORT flag on socket to allow multiple instances binding on the same address (BSD only).

Registers the given socket(s) for further use.

Parameters:socket (Socket|list[Socket]) – Socket type object. See .sockets.
set_ssl_params(*, verbose_errors=None, sessions_cache=None, sessions_timeout=None, session_context=None, raw_options=None, dir_tmp=None, client_cert_var=None)
  • verbose_errors (bool) – Be verbose about SSL errors.
  • sessions_cache (str|bool) –

    Use uWSGI cache for ssl sessions storage.

    Accepts either bool or cache name string.


    Please be sure to configure cache before setting this.

  • sessions_timeout (int) – Set SSL sessions timeout in seconds. Default: 300.
  • session_context (str) –

    Session context identifying string. Can be set to static shared value to avoid session rejection.

    Default: a value built from the HTTP server address.

  • raw_options (int|list[int]) – Set a raw ssl option by its numeric value.
  • dir_tmp (str) – Store ssl-related temp files (e.g. pem data) in the specified directory.
  • client_cert_var (str) – Export uWSGI variable HTTPS_CC containing the raw client certificate.
set_sni_params(name: str, *, cert: str, key: str, ciphers: str = None, client_ca: str = None, wildcard: bool = False)

Allows setting Server Name Identification (virtual hosting for SSL nodes) params.

  • name – Node/server/host name.
  • cert – Certificate file.
  • key – Private key file.
  • ciphers

    Ciphers [alias] string.

    • HIGH
    • DHE, EDH
  • client_ca

    Client CA file for client-based auth.

  • wildcard – Allow regular expressions in name (used for wildcard certificates).
set_sni_dir_params(dir, ciphers=None)

Enable checking for cert/key/client_ca file in the specified directory and create a sni/ssl context on demand.

Expected filenames:
  • <sni-name>.crt
  • <sni-name>.key
  • <sni-name>.ca - this file is optional