REST API Access

    +

    Description — Sync Gateway REST API Access
    Abstract — Shows how to access Sync Gateway APIs
    Related Content — Public REST API | Metrics REST API | Use the REST API?

    Sync Gateway APIs are accessed on different TCP ports. This makes it easy to expose the Public REST API (port 4984) to endpoints while keeping the Admin REST API (port 4985) secure behind your firewall.

    Prometheus Monitoring Support

    This is a Developer Preview feature, not intended for production use; the API is uncommitted.

    In addition to the Admin API’s expvar endpoint, you can now try the developer preview of Sync Gateway’s Metrics REST API, which exposes those same statistics in a Prometheus-compatible format — see Metrics REST API.

    For more information on using Prometheus and Grafina with Sync Gateway — see our blog entry Monitoring Couchbase Sync Gateway with Prometheus and Grafana.

    If you want to change the ports, you can do that in the configuration file, so:

    • To change the Public REST API port, set the interface property in the configuration file.

    • To change the Admin REST API port, set the adminInterface property in the configuration file.

    The value of the property is a string consisting of a colon followed by a port number (for example, :4985). You can also prepend a host name or numeric IP address before the colon to bind only to the network interface with that address.

    As a useful special case, the IP address 127.0.0.1 binds to the loopback interface, making the port unreachable from any other host. This is the default setting for the admin interface.

    Network Port Requirements

    Sync Gateway uses specific ports for communication with the outside world, mostly Couchbase Lite databases replicating to and from Sync Gateway — see Table 1 for details.

    Table 1. Sync Gateway Network Port Requirements
    Port Description

    4984

    Public port. External HTTP port used for replication with Couchbase Lite databases and other applications accessing the REST API on the Internet.

    The Public REST API is used for client replication. The default port for the Public REST API is 4984.

    4985

    Admin port. Internal HTTP port for unrestricted access to the database and to run administrative tasks.

    The Admin REST API is used to administer user accounts and roles. It can also be used to look at the contents of databases in superuser mode. The default port for the Admin REST API is 4985. By default, the Admin REST API is reachable only from localhost for safety reasons.