Skip to content

DB_POSTGRES module

Module description

The following modules must be loaded before this module:

  • No dependencies on other OpenSIPS modules.

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • PostgreSQL library - e.g., libpq5.
  • PostgreSQL devel library - to compile the module (e.g., libpq-dev).

If queries take longer than ‘exec_query_threshold’ microseconds, warning messages will be written to logging facility.

Default value is 0 - disabled.

Set exec_query_threshold parameter
...
modparam("db_postgres", "exec_query_threshold", 60000)
...

The maximum number of database queries to be executed. If this parameter is set improperly, it is set to default value.

Default value is 2.

Set max_db_queries parameter
...
modparam("db_postgres", "max_db_queries", 2)
...

The number of seconds the PostgreSQL library waits to connect and query the server. If the connection does not succeed within the given timeout, the connection fails.

Default value is 5.

Set timeout parameter
...
modparam("db_postgres", "timeout", 2)
...

Parameter to control the way the SSL support is used when connecting to the Postgres server, as follows:

  • use_tls=0 (default) - the SSL support is disabled and there is no attempt to use it;
  • use_tls=1 with “tls_domain” present in the DB URL - the SSL support is enabled, either “require”, either “verify-ca”, depending on the certificate settings;
  • use_tls=1 with no “tls_domain” present in the DB URL - the SSL support is enabled in best effort mode (or “prefer”); if supported by the server, it will be used, otherwise it will fall back to non-SSL.

Setting this parameter will allow you to use TLS for PostgreSQL connections. In order to enable TLS for a specific connection, you can use the “tls_domain=dom_name” URL parameter in the db_url of the respective OpenSIPS module. This should be placed at the end of the URL after the ’?’ character.

When using this parameter, you must also ensure that tls_mgm is loaded and properly configured. Refer to the the module for additional info regarding TLS client domains.

Also, you can NOT enable TLS for the connection to the database of the tls_mgm module itself.

Default value is 0 (not enabled)

Set the use_tls parameter
...
modparam("tls_mgm", "client_domain", "dom1")
modparam("tls_mgm", "certificate", "[dom1]/etc/pki/tls/certs/opensips.pem")
modparam("tls_mgm", "private_key", "[dom1]/etc/pki/tls/private/opensips.key")
modparam("tls_mgm", "ca_list", "[dom1]/etc/pki/tls/certs/ca.pem")
...
modparam("db_postgres", "use_tls", 1)
...
modparam("usrloc", "db_url", "postgres://root:1234@localhost/opensips?tls_domain=dom1")
...

NONE

Notes about installation and running.

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Henning Westerholt (@henningw)1223127214094
2.Bogdan-Andrei Iancu (@bogdan-iancu)784512251282
3.Norman Brandinger (@NormB)58615012299
4.Greg Fausak42344722
5.Daniel-Constantin Mierla (@miconda)2820375228
6.Liviu Chircu (@liviuchircu)1915115157
7.Razvan Crainea (@razvancrainea)161321229
8.Jan Janak (@janakj)12830831
9.Vlad Paiu (@vladpaiu)11713466
10.Klaus Darilion10613967

All remaining contributors: Maksym Sobolyev (@sobomax), Vlad Patrascu (@rvlad-patrascu), Stefan Darius (@dariusstefan), Ancuta Onofrei, Dusan Klinec (@ph4r05), Andrei Pelinescu-Onciul, Ruslan Bukin, Eseanu Marius Cristian (@eseanucristian), Ryan Bullock (@rrb3942), Razvan Pistolea, Konstantin Bokarius, Ken Rice, Dan Pascu (@danpascu), Peter Lemenkov (@lemenkov), Aron Podrigal (@ar45), Edson Gellert Schubert, Jarrod Baumann (@jarrodb).

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
2.Razvan Crainea (@razvancrainea)Oct 2011 - Jun 2026
3.Ken RiceSep 2025 - Sep 2025
4.Liviu Chircu (@liviuchircu)Sep 2012 - May 2024
5.Bogdan-Andrei Iancu (@bogdan-iancu)Jul 2005 - Feb 2024
6.Maksym Sobolyev (@sobomax)Apr 2004 - Feb 2023
7.Vlad Patrascu (@rvlad-patrascu)May 2017 - Oct 2021
8.Norman Brandinger (@NormB)Aug 2006 - Oct 2021
9.Dan Pascu (@danpascu)May 2019 - May 2019
10.Ryan Bullock (@rrb3942)Mar 2019 - Mar 2019

All remaining contributors: Vlad Paiu (@vladpaiu), Peter Lemenkov (@lemenkov), Jarrod Baumann (@jarrodb), Dusan Klinec (@ph4r05), Aron Podrigal (@ar45), Eseanu Marius Cristian (@eseanucristian), Razvan Pistolea, Ruslan Bukin, Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Ancuta Onofrei, Klaus Darilion, Jan Janak (@janakj), Greg Fausak, Andrei Pelinescu-Onciul.

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Vlad Patrascu (@rvlad-patrascu), Norman Brandinger (@NormB), Liviu Chircu (@liviuchircu), Peter Lemenkov (@lemenkov), Aron Podrigal (@ar45), Eseanu Marius Cristian (@eseanucristian), Vlad Paiu (@vladpaiu), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw), Jan Janak (@janakj).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0