Connect to external PostgreSQL from Local?

Issue Summary

Our team uses Local for development. We recently encountered a need to query a PostgreSQL database in AWS from within a WordPress template. Our host’s PHP installation supports PostgreSQL, and the script works when run from the host’s server, but I don’t know how to adjust Local to support PHP functions like pg_pconnect() and pg_query().

Troubleshooting Questions

Local is working great. The only problem I encounter is when trying to use functions like pg_pconnect() and pg_query() to access external resources. They’re apparently not supported by Local’s out-of-the-box PHP config. When I try to connect to a PostgreSQL resource, I get an error saying “Call to undefined function pg_connect()”.

I can find general instructions online for installing Postgres support for PHP on MacOS, but the “installation” of PHP used within my Local site(s) doesn’t seem to be recognized in my terminal. I’m not surprised - I sort of assume it’s wrapped in a container of some kind and not generally available at an OS level. In this situation, I don’t know how to approach adding Postgres support to Local, or if it’s even possible. Any thoughts?

System Details

  • Local version 6.3.1+5826

  • MacOS Monterey 12.3.1 (21E258) - Macbook Pro (M1 chip)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.