Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Docker

How to Install and Configure pgAdmin 4 in Server Mode

By Freedom251 Team · · 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

pgAdmin 4 server mode runs as a multi-user web application rather than a single desktop window. Install it on a host or deploy the official container, initialize an administrator account, run one Python process, and place a correctly configured reverse proxy in front when needed. If you publish it below /pgadmin4 instead of at the site root, coordinate the application’s SCRIPT_NAME, proxy paths, headers, and cookie scope or login redirects will point to the wrong location.

What server mode is and why the setup matters

From pgAdmin 4 version 2 onward, server mode is the default configuration. The desktop runtime changes that behavior automatically, but a web deployment does not: users must authenticate before using pgAdmin, and initialization creates an initial superuser. That account can later create additional superusers and ordinary users.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Each user’s file access is confined to a virtual root beneath the configured STORAGE_DIR. The service therefore needs write access to its configuration database, session storage, and storage directories, while those locations should remain inaccessible to unrelated operating-system users.

pgAdmin features that depend on affinity to one database connection require a single Python process. You can use threads inside that process, but do not increase the number of Python workers unless your architecture explicitly preserves the required connection affinity. The commonly shown Gunicorn setting of one worker and 25 threads is an example configuration, not a throughput or user-capacity guarantee.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose a deployment shape before installing

Decision Host-managed installation Container installation
Packaging Install a native package or Python wheel and manage the service with the host’s process tooling. Run the official dpage/pgadmin4 image and manage it with Docker or a Kubernetes-style platform.
Web serving Serve through Apache HTTPD with mod_wsgi, standalone Gunicorn, standalone uWSGI, or a reverse proxy such as NGINX or Caddy. Expose the container’s HTTP or TLS listener directly, or put your platform ingress/reverse proxy in front of it.
Persistence Keep the configuration database, sessions, and STORAGE_DIR on protected host paths writable by the service account. Map the image’s documented pgAdmin data and configuration directories to persistent volumes.
Restricted security context Use the ports and permissions allowed by the host service account. The entrypoint supports non-privileged listeners such as HTTP 8080 and TLS 8443 when privileged ports are unavailable.
URL layout Can be mounted at the domain root or under a prefix such as /pgadmin4. Use the same prefix rules when an ingress publishes the container below a subdirectory.

Choose a host-managed deployment when operating-system service management and local filesystem control are important. Choose the container when image-based upgrades, orchestration, or a restricted runtime are the better fit. In either case, the application-level requirements are the same: first-run authentication, writable state, one Python process, and correctly forwarded scheme and script-name information.

Install pgAdmin 4 on a host

Install the package or wheel in the service environment

Install the pgAdmin 4 native package supplied for your operating system, or install the Python wheel into the virtual environment that will run the WSGI application. Keep the application and its state directories separate from temporary build files, and record the account that will own the service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume that the account used for installation is the account used by Apache, Gunicorn, or uWSGI. The runtime account must be able to create and modify the configuration database, session files, and every path under STORAGE_DIR. Give those directories the minimum ownership and mode required by the service; do not make them broadly writable as a shortcut.

Add local configuration without editing the shipped file

When the defaults need to change, create config_local.py beside pgAdmin’s shipped config.py. Keep deployment-specific values in that local file so package upgrades do not overwrite them. Typical settings include storage locations, session behavior, and other site-level options that your chosen deployment requires.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

After creating or changing the file, restart the web process. Validate that the process account can read the file and write the configured state paths before attempting the first login; a permissions failure at this stage often appears as a generic server error in the browser.

Initialize the first administrator

  1. Start pgAdmin through the selected WSGI server or web-serving integration.
  2. Open the published URL from a browser.
  3. Complete the first-run form with the email address and password for the initial superuser.
  4. Sign in with that account and create additional superusers or non-superusers as required.

Server mode does not provide anonymous access. Protect the initial credentials as you would any other administrative account, and use HTTPS before exposing the login page beyond a trusted local network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run pgAdmin with Gunicorn or another WSGI server

Use one worker and threads only inside that process

A representative Gunicorn launch uses one worker and multiple threads:

gunicorn --workers=1 --threads=25 pgadmin4.pgAdmin4:app

The module path and executable location must match the package or wheel installation on your host. Treat --workers=1 --threads=25 as an illustrative starting point from the deployment guidance, not as a sizing recommendation. If you use uWSGI, apply the same single-Python-process constraint and adapt its module, socket, and environment settings to your installation.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Choose a direct listener or a local socket

For a private network, Gunicorn or uWSGI can listen on a local TCP port. A reverse proxy can instead connect over a Unix socket, keeping the application listener off the network. Whichever transport you choose, ensure the proxy account can reach the socket or port and that the host firewall does not expose an unintended administrative endpoint.

Apache HTTPD and other supported front ends

Apache HTTPD with mod_wsgi, standalone Gunicorn, standalone uWSGI, NGINX, and Caddy are all supported deployment patterns. The critical behavior is not the brand of front end; it is that the front end forwards the original scheme and any configured URL prefix while preventing clients from supplying those values themselves.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put NGINX or Caddy in front of pgAdmin

Forward only trusted scheme and script-name headers

pgAdmin honors X-Script-Name and X-Scheme unconditionally. A reverse proxy must therefore overwrite or remove incoming values before forwarding the request. Otherwise a client can influence the URL pgAdmin constructs for redirects, links, or cookies.

  • Set X-Scheme to the scheme used by the public request, normally the value represented by the proxy’s HTTPS termination.
  • Set X-Script-Name to the public path prefix when pgAdmin is mounted below a subdirectory; omit it or set it consistently for a root deployment.
  • Pass the request to the local Gunicorn or uWSGI TCP listener or Unix socket.
  • Preserve the host and forwarding information required by your TLS and virtual-host arrangement.

In NGINX, define a location for the application path and explicitly set the headers rather than allowing client-provided values to pass through. Caddy and other proxies need the same logical treatment even though their configuration syntax differs.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Root URL deployment

When pgAdmin is published at the domain root, proxy requests for / and its descendants to the WSGI server, set the scheme header to the externally visible scheme, and avoid adding a script-name prefix. Test both the login page and a post-login navigation link so that redirects stay on the same host and scheme.

Subdirectory deployment at /pgadmin4

A prefix deployment requires three pieces to agree:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Set SCRIPT_NAME=/pgadmin4 in the Gunicorn or uWSGI environment.
  2. Preserve the /pgadmin4 prefix in the reverse-proxy routing and set X-Script-Name: /pgadmin4 on forwarded requests.
  3. Scope session cookies and any application URL rewriting to the same public path.

Proxy both the bare prefix and descendants. In NGINX terms, handle an exact /pgadmin4 location as well as a /pgadmin4/ location. The bare path is often redirected to add a trailing slash; if that request is not proxied, the redirect can escape to the site root.

A minimal header portion of a prefix-aware proxy looks like this:

proxy_set_header X-Script-Name /pgadmin4;
proxy_set_header X-Scheme $scheme;
proxy_pass http://127.0.0.1:5050;

Use the equivalent directives for your socket or upstream definition, and ensure the proxy does not accept a client-supplied value for either header. If login sends you to /login instead of /pgadmin4/login, or if the browser repeatedly bounces between the two paths, check all three prefix settings before changing application code.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Deploy the official container

Set first-run credentials

The official image is dpage/pgadmin4. Supply PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD when creating the container so the first-run administrator can be initialized non-interactively. Treat those values as secrets: use your platform’s secret mechanism rather than committing them to a compose file or shell history where possible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To enable TLS in the image, set PGADMIN_ENABLE_TLS=True and mount the certificate and private key at the locations expected by the image configuration. If TLS terminates at an ingress instead, keep the external scheme and forwarded headers consistent with the proxy rules described above.

Persist state with volumes

Map the container’s documented pgAdmin data and configuration directories to persistent volumes. Without those mounts, the configuration database, sessions, saved server registrations, and other state can disappear when the container is replaced. The volume must be writable by the user under which the image runs.

Use PGADMIN_CONFIG_ environment variables for settings that must be injected at container creation, but prefer a persistent config_local.py for durable local overrides when the image supports mounting it. Keep one authoritative source for each setting so an environment override does not silently contradict the file.

Understand servers.json initialization

A servers.json file is read when the pgAdmin configuration database is created for the first time. It is not re-imported on every restart. To apply a changed server definition, follow the image’s import procedure or recreate the configuration database deliberately after preserving any data you need; simply restarting an existing container will not reload the file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run in restricted environments

OpenShift-style security contexts and containers started with --cap-drop=ALL are supported. When the runtime cannot bind privileged ports, configure the image or platform to use non-privileged HTTP port 8080 or TLS port 8443, then expose those ports through the service or ingress. Confirm that the mounted data directories remain writable under the restricted container identity.

Secure and operate the installation

  • Encrypt the session: terminate HTTPS at the reverse proxy or enable container TLS before allowing untrusted users to reach the login form.
  • Protect state: restrict configuration, session, and storage directories to the pgAdmin service account and trusted administrators.
  • Keep one Python process: do not scale Gunicorn or uWSGI workers horizontally unless the deployment preserves the connection affinity required by pgAdmin features.
  • Sanitize proxy headers: overwrite or remove incoming X-Script-Name and X-Scheme values.
  • Keep prefix settings together: configure SCRIPT_NAME, proxy path matching, forwarded headers, and cookie scope as one change.
  • Back up persistent state: include the configuration database and storage directory in the same backup plan, and test restoration rather than backing up only the container image.
  • Separate secrets from configuration: protect the initial superuser password and any TLS private key from source control and general-read filesystem permissions.

Troubleshoot common failures

Symptom Likely cause What to check
Login redirects to the domain root from a /pgadmin4 installation SCRIPT_NAME, X-Script-Name, or proxy path handling is missing. Set the environment value and header to /pgadmin4, proxy both the bare and trailing-slash paths, and verify cookie scope.
Repeated redirect loop at the prefix The bare-prefix request is not reaching pgAdmin, or the proxy and application disagree about the trailing slash. Add an exact match for /pgadmin4 alongside the descendant location and inspect the Location response header.
Unexpected redirects or links use the wrong scheme A client-supplied or incorrect X-Scheme value is reaching the application. Overwrite the header at the proxy with the externally visible scheme.
First run fails with a database or session write error The runtime account cannot write configured state directories. Check ownership and permissions for the configuration database, session storage, and STORAGE_DIR.
Container loses users or settings after replacement State was stored only in the writable container layer. Map the documented data/configuration directories to persistent volumes and verify they survive a restart.
Imported servers do not change after editing servers.json The file is an initialization input, not a continuously watched file. Use the image’s import process or recreate the configuration database according to your retention plan.
Features behave inconsistently with multiple workers Requests are moving between Python processes without the required database-connection affinity. Return to one worker and use threads within that process, then retest.
Container cannot bind the selected port The security context does not permit privileged ports. Use a non-privileged listener such as 8080 for HTTP or 8443 for TLS and publish it through the platform service.

Pre-launch verification

  1. Confirm whether the service is published at the root or under a prefix, and write that decision into the proxy configuration.
  2. Verify that the chosen package, wheel, or container starts the pgAdmin WSGI application successfully.
  3. Check that exactly one Python worker is configured.
  4. Test write access as the actual service or container identity to the configuration database, session directory, and STORAGE_DIR.
  5. Create and protect the initial superuser, then test a second account with the intended permission level.
  6. Test login, logout, a post-login redirect, and a browser refresh through the public URL.
  7. If using a prefix, test both /pgadmin4 and /pgadmin4/, including an unauthenticated request.
  8. Confirm HTTPS behavior, sanitized forwarding headers, persistent volumes, and backup coverage before opening access to users.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

DockerGunicornNGINXpgAdmin 4PostgreSQLserver modeuWSGI

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.