# pgweb — Web-Based PostgreSQL Database Browser > pgweb is a cross-platform web GUI for PostgreSQL written in Go. It provides a clean browser interface for running queries, browsing tables, and exporting data, all from a single binary with no dependencies. ## Install Save as a script file and run: # pgweb — Web-Based PostgreSQL Database Browser ## Quick Use ```bash # Install via Homebrew brew install pgweb # Or download the binary curl -L https://github.com/sosedoff/pgweb/releases/latest/download/pgweb_linux_amd64.zip -o pgweb.zip unzip pgweb.zip # Connect to a database pgweb --host localhost --user postgres --db mydb # Or use a connection string pgweb --url "postgres://postgres:password@localhost:5432/mydb?sslmode=disable" # Open http://localhost:8081 in your browser ``` ## Introduction pgweb gives you a browser-based interface to explore PostgreSQL databases without installing heavy desktop tools. It ships as a single Go binary that connects to your Postgres instance and serves a web UI for ad-hoc queries, table browsing, and data export. It is especially useful on remote servers where you only have SSH access. ## What pgweb Does - Provides a SQL query editor with syntax highlighting and query history - Displays table structure, indexes, constraints, and row data in a browsable grid - Exports query results to CSV, JSON, or XML formats - Supports multiple simultaneous database connections via bookmarks - Handles SSH tunnel connections for accessing remote databases securely ## Architecture Overview pgweb is a single Go binary that embeds a web server and static frontend assets. On startup it connects to PostgreSQL using the standard lib/pq driver. The frontend sends SQL queries via a REST API to the Go backend, which executes them and returns JSON results. There is no separate database or state; session data lives in memory for the duration of the process. ## Self-Hosting & Configuration - Single binary with no runtime dependencies; runs on Linux, macOS, and Windows - Configure via CLI flags or environment variables for host, port, user, and database - Supports SSL connections with configurable certificate paths - Set --bind and --listen to control which interface and port the web UI listens on - Use --readonly mode to prevent any data modification queries in shared environments ## Key Features - Zero-dependency single binary deployment with embedded web interface - Built-in SSH tunnel support for connecting to databases behind firewalls - Bookmarks for saving and switching between multiple database connections - Query history preserved across browser sessions for quick recall - Read-only mode for safe database exploration in production environments ## Comparison with Similar Tools - **pgAdmin** — Full-featured GUI with visual query builder and server management; much heavier - **DBeaver** — Universal database tool supporting many databases; desktop app with Java dependency - **Adminer** — PHP-based web database manager; supports more databases but requires a PHP runtime - **pgcli** — Terminal-based PostgreSQL client with auto-completion; CLI-only, no web UI - **CloudBeaver** — Web-based DBeaver; more features but requires Docker and significantly more resources ## FAQ **Q: Can pgweb modify data or just read it?** A: By default it allows full SQL execution including INSERT, UPDATE, and DELETE. Use --readonly flag to restrict to SELECT only. **Q: Does it support multiple users?** A: pgweb does not have built-in user management. For multi-user access, place it behind a reverse proxy with authentication. **Q: Can I connect to multiple databases at once?** A: Yes, using bookmarks or by opening multiple browser tabs with different connection parameters. **Q: Is it safe to expose pgweb to the internet?** A: Not without a reverse proxy providing TLS and authentication. pgweb itself has no built-in auth beyond the database credentials. ## Sources - https://github.com/sosedoff/pgweb - https://sosedoff.github.io/pgweb/ --- Source: https://tokrepo.com/en/workflows/029bbd07-3abe-11f1-9bc6-00163e2b0d79 Author: Script Depot