How Do You Troubleshoot a 500 URL Return Code with a PHP Web Page That Is Using pg_connect?

Problem scenario
You have an Apache web server with PHP code.  You are trying to integrate web pages with Postgresql.  When browsing to a web page (.php), you are getting a 500 URL return code.  Your PHP web page file is using the reserved command "pg_connect."  How do you overcome this 500 URL return code error and have the web page work?

Solution
Possible solution #1:  Reboot the web server.

Possible solution #2:  Assuming other web pages work and the 500 URL return code only applies to a PHP file that is using pg_connect, there may be a blockage from the IP address of the client with the web browser. Another problem may be that the Postgres server is unreachable.  There could be a DNS issue (the FQDN of the Postgres server is not resolving to the IP address correctly) or a key port is blocked (TCP port 5432).  Try using the IP address instead of the FQDN of the Postgres server in the PHP page (e.g., for the $host value).

Leave a comment

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