Skip to content

[MacOS] How to Resolve 'Can't find the libpq-fe.h header' Error

Published: at 12:55 PM (1 min read)

Problem

When installing the pg gem, you might encounter the following error:

checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

This usually means the PostgreSQL development headers are missing.

Solution

To resolve this issue, you need to install PostgreSQL

brew install postgresql

After installing PostgreSQL, you can retry the installation of the pg gem

# Install the pg gem
gem install pg

# or if you're using Bundler
bundle install

Previous Post
[N8N] Fixing Express 'trust proxy' and X-Forwarded-For Error (express-rate-limit)
Next Post
[MacOS] How to Resolve 'ERROR: CMake is required to build Rugged.'