{
    "mode": "man",
    "parameter": "pg_recvlogical",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pg_recvlogical/1/json",
    "generated": "2026-06-14T00:17:03Z",
    "synopsis": "pgrecvlogical [option...]",
    "sections": {
        "NAME": {
            "content": "pgrecvlogical - control PostgreSQL logical decoding streams\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pgrecvlogical [option...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "pgrecvlogical controls logical decoding replication slots and streams data from such\nreplication slots.\n\nIt creates a replication-mode connection, so it is subject to the same constraints as\npgreceivewal(1), plus those for logical replication (see Chapter 49).\n\npgrecvlogical has no equivalent to the logical decoding SQL interface's peek and get modes.\nIt sends replay confirmations for data lazily as it receives it and on clean exit. To examine\npending data on a slot without consuming it, use pglogicalslotpeekchanges.\n\nWhen pgrecvlogical receives a SIGHUP signal, it closes the current output file and opens a\nnew one using the filename specified by the --file option. This allows us to rotate the\noutput file by first renaming the current file and then sending a SIGHUP signal to\npgrecvlogical.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "At least one of the following options must be specified to select an action:\n",
            "subsections": [
                {
                    "name": "--create-slot",
                    "content": "Create a new logical replication slot with the name specified by --slot, using the output\nplugin specified by --plugin, for the database specified by --dbname.\n",
                    "long": "--create-slot"
                },
                {
                    "name": "--drop-slot",
                    "content": "Drop the replication slot with the name specified by --slot, then exit.\n",
                    "long": "--drop-slot"
                },
                {
                    "name": "--start",
                    "content": "Begin streaming changes from the logical replication slot specified by --slot, continuing\nuntil terminated by a signal. If the server side change stream ends with a server\nshutdown or disconnect, retry in a loop unless --no-loop is specified.\n\nThe stream format is determined by the output plugin specified when the slot was created.\n\nThe connection must be to the same database used to create the slot.\n\n--create-slot and --start can be specified together.  --drop-slot cannot be combined with\nanother action.\n\nThe following command-line options control the location and format of the output and other\nreplication behavior:\n",
                    "long": "--start"
                },
                {
                    "name": "-E",
                    "content": "--endpos=lsn\nIn --start mode, automatically stop replication and exit with normal exit status 0 when\nreceiving reaches the specified LSN. If specified when not in --start mode, an error is\nraised.\n\nIf there's a record with LSN exactly equal to lsn, the record will be output.\n\nThe --endpos option is not aware of transaction boundaries and may truncate output\npartway through a transaction. Any partially output transaction will not be consumed and\nwill be replayed again when the slot is next read from. Individual messages are never\ntruncated.\n",
                    "flag": "-E"
                },
                {
                    "name": "-f",
                    "content": "--file=filename\nWrite received and decoded transaction data into this file. Use - for stdout.\n",
                    "flag": "-f"
                },
                {
                    "name": "-F",
                    "content": "--fsync-interval=intervalseconds\nSpecifies how often pgrecvlogical should issue fsync() calls to ensure the output file\nis safely flushed to disk.\n\nThe server will occasionally request the client to perform a flush and report the flush\nposition to the server. This setting is in addition to that, to perform flushes more\nfrequently.\n\nSpecifying an interval of 0 disables issuing fsync() calls altogether, while still\nreporting progress to the server. In this case, data could be lost in the event of a\ncrash.\n",
                    "flag": "-F"
                },
                {
                    "name": "-I",
                    "content": "--startpos=lsn\nIn --start mode, start replication from the given LSN. For details on the effect of this,\nsee the documentation in Chapter 49 and Section 53.4. Ignored in other modes.\n",
                    "flag": "-I"
                },
                {
                    "name": "--if-not-exists",
                    "content": "Do not error out when --create-slot is specified and a slot with the specified name\nalready exists.\n",
                    "long": "--if-not-exists"
                },
                {
                    "name": "-n",
                    "content": "",
                    "flag": "-n"
                },
                {
                    "name": "--no-loop",
                    "content": "When the connection to the server is lost, do not retry in a loop, just exit.\n",
                    "long": "--no-loop"
                },
                {
                    "name": "-o",
                    "content": "--option=name[=value]\nPass the option name to the output plugin with, if specified, the option value value.\nWhich options exist and their effects depends on the used output plugin.\n",
                    "flag": "-o"
                },
                {
                    "name": "-P",
                    "content": "--plugin=plugin\nWhen creating a slot, use the specified logical decoding output plugin. See Chapter 49.\nThis option has no effect if the slot already exists.\n",
                    "flag": "-P"
                },
                {
                    "name": "-s",
                    "content": "--status-interval=intervalseconds\nThis option has the same effect as the option of the same name in pgreceivewal(1). See\nthe description there.\n",
                    "flag": "-s"
                },
                {
                    "name": "-S",
                    "content": "--slot=slotname\nIn --start mode, use the existing logical replication slot named slotname. In\n--create-slot mode, create the slot with this name. In --drop-slot mode, delete the slot\nwith this name.\n",
                    "flag": "-S"
                },
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "--verbose",
                    "content": "Enables verbose mode.\n\nThe following command-line options control the database connection parameters.\n",
                    "long": "--verbose"
                },
                {
                    "name": "-d",
                    "content": "--dbname=dbname\nThe database to connect to. See the description of the actions for what this means in\ndetail. The dbname can be a connection string. If so, connection string parameters will\noverride any conflicting command line options. Defaults to the user name.\n",
                    "flag": "-d"
                },
                {
                    "name": "-h",
                    "content": "--host=hostname-or-ip\nSpecifies the host name of the machine on which the server is running. If the value\nbegins with a slash, it is used as the directory for the Unix domain socket. The default\nis taken from the PGHOST environment variable, if set, else a Unix domain socket\nconnection is attempted.\n",
                    "flag": "-h"
                },
                {
                    "name": "-p",
                    "content": "--port=port\nSpecifies the TCP port or local Unix domain socket file extension on which the server is\nlistening for connections. Defaults to the PGPORT environment variable, if set, or a\ncompiled-in default.\n",
                    "flag": "-p"
                },
                {
                    "name": "-U",
                    "content": "--username=user\nUser name to connect as. Defaults to current operating system user name.\n",
                    "flag": "-U"
                },
                {
                    "name": "-w",
                    "content": "",
                    "flag": "-w"
                },
                {
                    "name": "--no-password",
                    "content": "Never issue a password prompt. If the server requires password authentication and a\npassword is not available by other means such as a .pgpass file, the connection attempt\nwill fail. This option can be useful in batch jobs and scripts where no user is present\nto enter a password.\n",
                    "long": "--no-password"
                },
                {
                    "name": "-W",
                    "content": "",
                    "flag": "-W"
                },
                {
                    "name": "--password",
                    "content": "Force pgrecvlogical to prompt for a password before connecting to a database.\n\nThis option is never essential, since pgrecvlogical will automatically prompt for a\npassword if the server demands password authentication. However, pgrecvlogical will\nwaste a connection attempt finding out that the server wants a password. In some cases it\nis worth typing -W to avoid the extra connection attempt.\n\nThe following additional options are available:\n",
                    "long": "--password"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "--version",
                    "content": "Print the pgrecvlogical version and exit.\n\n-?",
                    "long": "--version"
                },
                {
                    "name": "--help",
                    "content": "Show help about pgrecvlogical command line arguments, and exit.\n",
                    "long": "--help"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "This utility, like most other PostgreSQL utilities, uses the environment variables supported\nby libpq (see Section 34.15).\n\nThe environment variable PGCOLOR specifies whether to use color in diagnostic messages.\nPossible values are always, auto and never.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "pgrecvlogical will preserve group permissions on the received WAL files if group permissions\nare enabled on the source cluster.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "See Section 49.1 for an example.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pgreceivewal(1)\n\n\n\nPostgreSQL 14.23                                2026                               PGRECVLOGICAL(1)",
            "subsections": []
        }
    },
    "summary": "pgrecvlogical - control PostgreSQL logical decoding streams",
    "flags": [
        {
            "flag": "",
            "long": "--create-slot",
            "arg": null,
            "description": "Create a new logical replication slot with the name specified by --slot, using the output plugin specified by --plugin, for the database specified by --dbname."
        },
        {
            "flag": "",
            "long": "--drop-slot",
            "arg": null,
            "description": "Drop the replication slot with the name specified by --slot, then exit."
        },
        {
            "flag": "",
            "long": "--start",
            "arg": null,
            "description": "Begin streaming changes from the logical replication slot specified by --slot, continuing until terminated by a signal. If the server side change stream ends with a server shutdown or disconnect, retry in a loop unless --no-loop is specified. The stream format is determined by the output plugin specified when the slot was created. The connection must be to the same database used to create the slot. --create-slot and --start can be specified together. --drop-slot cannot be combined with another action. The following command-line options control the location and format of the output and other replication behavior:"
        },
        {
            "flag": "-E",
            "long": null,
            "arg": null,
            "description": "--endpos=lsn In --start mode, automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN. If specified when not in --start mode, an error is raised. If there's a record with LSN exactly equal to lsn, the record will be output. The --endpos option is not aware of transaction boundaries and may truncate output partway through a transaction. Any partially output transaction will not be consumed and will be replayed again when the slot is next read from. Individual messages are never truncated."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": "--file=filename Write received and decoded transaction data into this file. Use - for stdout."
        },
        {
            "flag": "-F",
            "long": null,
            "arg": null,
            "description": "--fsync-interval=intervalseconds Specifies how often pgrecvlogical should issue fsync() calls to ensure the output file is safely flushed to disk. The server will occasionally request the client to perform a flush and report the flush position to the server. This setting is in addition to that, to perform flushes more frequently. Specifying an interval of 0 disables issuing fsync() calls altogether, while still reporting progress to the server. In this case, data could be lost in the event of a crash."
        },
        {
            "flag": "-I",
            "long": null,
            "arg": null,
            "description": "--startpos=lsn In --start mode, start replication from the given LSN. For details on the effect of this, see the documentation in Chapter 49 and Section 53.4. Ignored in other modes."
        },
        {
            "flag": "",
            "long": "--if-not-exists",
            "arg": null,
            "description": "Do not error out when --create-slot is specified and a slot with the specified name already exists."
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--no-loop",
            "arg": null,
            "description": "When the connection to the server is lost, do not retry in a loop, just exit."
        },
        {
            "flag": "-o",
            "long": null,
            "arg": null,
            "description": "--option=name[=value] Pass the option name to the output plugin with, if specified, the option value value. Which options exist and their effects depends on the used output plugin."
        },
        {
            "flag": "-P",
            "long": null,
            "arg": null,
            "description": "--plugin=plugin When creating a slot, use the specified logical decoding output plugin. See Chapter 49. This option has no effect if the slot already exists."
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": "--status-interval=intervalseconds This option has the same effect as the option of the same name in pgreceivewal(1). See the description there."
        },
        {
            "flag": "-S",
            "long": null,
            "arg": null,
            "description": "--slot=slotname In --start mode, use the existing logical replication slot named slotname. In --create-slot mode, create the slot with this name. In --drop-slot mode, delete the slot with this name."
        },
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--verbose",
            "arg": null,
            "description": "Enables verbose mode. The following command-line options control the database connection parameters."
        },
        {
            "flag": "-d",
            "long": null,
            "arg": null,
            "description": "--dbname=dbname The database to connect to. See the description of the actions for what this means in detail. The dbname can be a connection string. If so, connection string parameters will override any conflicting command line options. Defaults to the user name."
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": "--host=hostname-or-ip Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "--port=port Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."
        },
        {
            "flag": "-U",
            "long": null,
            "arg": null,
            "description": "--username=user User name to connect as. Defaults to current operating system user name."
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--no-password",
            "arg": null,
            "description": "Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."
        },
        {
            "flag": "-W",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--password",
            "arg": null,
            "description": "Force pgrecvlogical to prompt for a password before connecting to a database. This option is never essential, since pgrecvlogical will automatically prompt for a password if the server demands password authentication. However, pgrecvlogical will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. The following additional options are available:"
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Print the pgrecvlogical version and exit. -?"
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Show help about pgrecvlogical command line arguments, and exit."
        }
    ],
    "examples": [
        "See Section 49.1 for an example."
    ],
    "see_also": [
        {
            "name": "pgreceivewal",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pgreceivewal/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Control PostgreSQL logical decoding streams.",
        "examples": [
            {
                "description": "Create a new logical replication slot",
                "command": "pg_recvlogical {{-d|--dbname}} {{dbname}} {{-S|--slot}} {{slot_name}} --create-slot"
            },
            {
                "description": "Start streaming changes from a logical replication slot to a file",
                "command": "pg_recvlogical {{-d|--dbname}} {{dbname}} {{-S|--slot}} {{slot_name}} --start {{-f|--file}} {{filename}}"
            },
            {
                "description": "Drop a logical replication slot",
                "command": "pg_recvlogical {{-d|--dbname}} {{dbname}} {{-S|--slot}} {{slot_name}} --drop-slot"
            },
            {
                "description": "Create a slot with two-phase commit enabled",
                "command": "pg_recvlogical {{-d|--dbname}} {{dbname}} {{-S|--slot}} {{slot_name}} --create-slot {{-t|--enable-two-phase}}"
            },
            {
                "description": "Display help",
                "command": "pg_recvlogical {{-?|--help}}"
            }
        ]
    }
}