【问题标题】:php pgadmin remote db connect failurephp pgadmin 远程数据库连接失败
【发布时间】:2011-02-24 06:53:39
【问题描述】:

我想从phppostgres 连接到远程数据库,但它无法连接并说

 Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server:    
could not connect to server: No route to host (0x00002751/10065) Is the server running on host "xxxxxxxxx" and accepting TCP/IP connections on port 5432? in C:\xampp\htdocs\test.php on line 4
Wrong CONN_STRING

<html> 
    <body> 
        <?php 
        $db = pg_connect('host=xxx.xxx.xxx.xxx port=5432 dbname=postgres user=postgres password=') or die('Wrong CONN_STRING'); 
        if (!$db) {
                echo 'error';
            }else{
            echo 'success';
            }

        ?> 
    </body> 

我可以从pgadmin 客户端访问相同的数据库,该客户端在运行 apache 的同一台机器上运行,我无法理解 pgadmin 可以访问 db 但 apache webserver 的 php 无法访问?有什么想法吗?

【问题讨论】:

标签: php connection phppgadmin


【解决方案1】:

“没有到主机的路由”告诉您存在某种网络问题 - 不同客户端能够从同一主机访问它的事实表明这是某种安全限制或防火墙阻止了连接,但如果没有有关您的环境的详细信息,就很难更具体。

【讨论】:

    【解决方案2】:

    这是 SELinux 的问题 以下命令解决了问题

    setsebool -P httpd_can_network_connect=1

    【讨论】:

      猜你喜欢
      • 2017-03-20
      • 1970-01-01
      • 2020-05-05
      • 2017-03-08
      • 2016-01-01
      • 1970-01-01
      • 2018-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多