pgweb
Browse and query a PostgreSQL database from the browser
pgweb is a web-based PostgreSQL browser. Rock8Cloud ships it as a one-click application so you can read rows, inspect schemas and run SQL against a database that has no public address.
Databases on Rock8Cloud are network-isolated - they only accept connections from services inside the same project. pgweb runs inside the project, so it can reach the database, and you reach pgweb over its own URL.
Create a pgweb Service
- Click Add Service in the project that holds the database
- Select Application
- Choose pgweb
- Pick a version (0.15.0, 0.16.2, or 0.17.0) and keep replicas at 1
- Copy the generated login password
- Link
PGWEB_DATABASE_URLto your PostgreSQL service's Connection URL - Click Deploy pgweb
pgweb comes up on its own public URL and asks for the generated credentials before it loads.
Environment Variables
| Variable | Description | Default |
|---|---|---|
PGWEB_DATABASE_URL | Connection string for the database pgweb browses | (linked) |
PGWEB_AUTH_USER | Login user | admin |
PGWEB_AUTH_PASS | Login password | (auto-generated) |
All three are ordinary environment variables. Change the user or password in the service's Environment tab and pgweb redeploys with the new login.
Which connection URL to link
Link the plain Connection URL, not the libpq-compatible variant. The libpq variant appends uselibpqcompat, a Go-specific flag that pgweb's driver rejects. Linking to the PostgreSQL service selects the right key for you.
The link is live rather than a copy, so rotating the database password does not require re-pasting anything into pgweb.
What You Can Do
| Tab | What it shows |
|---|---|
| Rows | Table data, with filtering |
| Structure | Columns, types and defaults |
| Indexes / Constraints | Table indexes and constraints |
| Query | A SQL editor, with Explain Query for a plan |
| History | Statements run in this session |
| Activity | What the database is doing right now |
| Connection | The connection pgweb is using |
Result sets export as JSON, CSV or XML.
Scope and Security
- Locked to one database - multiple sessions are disabled and the session is pinned to the linked connection, so a signed-in user cannot point pgweb at another host
- Full write access - anyone with the login can modify data, so treat the credentials as production access
- Public URL - the login is the only thing in front of the database. Use a strong password and rotate it from the Environment tab when someone who had it moves on
- Stop or delete when idle - a browser you are not using is access nobody is watching. Adding it back takes a couple of minutes
Troubleshooting
pgweb fails to start or cannot connect
- Confirm
PGWEB_DATABASE_URLis linked to the plain Connection URL, not the libpq-compatible one - Confirm the database is in the same project as the pgweb service
- Check the Logs tab on the pgweb service for the driver error
The browser does not ask for a login
PGWEB_AUTH_USERandPGWEB_AUTH_PASSmust both be set. If either is missing, redeploy with both present
Sign-in is rejected
- Check the current values in the Environment tab. The password shown on the add-service screen is only generated once, and editing the variable replaces it
Related
- PostgreSQL - provision the database pgweb browses
- Environment Variables - link and rotate service variables
- Service Configuration - replicas, resources and deploy history