当前位置: 澳门新濠3559 > 操作系统 > 正文

无法联接到服务器

时间:2019-11-20 22:05来源:操作系统
bash-4.1$ psql psql: 无法联接到服务器: 没有那个文件或目录 服务器是否在本地运行并且在 Unix 域套接字 "/var/run/postgresql/.s.PGSQL.5432"上准备接受联接? 问题原因:postgresql service stop 解决方法

图片 1

  • bash-4.1$ psql
    psql: 无法联接到服务器: 没有那个文件或目录
    服务器是否在本地运行并且在 Unix 域套接字
    "/var/run/postgresql/.s.PGSQL.5432"上准备接受联接?
    问题原因:postgresql service stop
    解决方法:service postgresql-9.6 start
  • psql: could not connect to server: Connection refused
    Is the server running on host "192.168.1.232" and accepting
    TCP/IP connections on port 5432?

磨砺技术珠矶,践行数据之道,追求卓越价值
回到上一级页面:PostgreSQL基础知识与基本操作索引页无法联接到服务器。    回到顶级页面:PostgreSQL索引页 [作者 高健@博客园  luckyjackgao@gmail.com]

jdbc连接SQL server连不上
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 127.0.0.1, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1195) at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at javaapplication3.JavaApplication3.JDBCon(JavaApplication3.java:27) at javaapplication3.JavaApplication3.main(JavaApplication3.java:18)图片 2

 

 

出现类似提示:

解决方法:
#vi postgresql.conf
修改 
#listen_addresses = 'localhost' 
为
listen_addresses = '*' 

错误类型1:

Failed to connect to the database: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
解决办法:service postgresql start

  • psql: FATAL: no pg_hba.conf entry for host "192.168.1.223", user "test", database "test", SSL off

[postgres@cent6 pgsql]$ ./bin/psql -h 192.168.246.134 -p 5432 -d postgres
psql: could not connect to server: Connection refused
Is the server running on host "16.157.246.134" and accepting
TCP/IP connections on port 5432?
[postgres@cent6 pgsql]$

 

这种是说 数据库服务器未允许 此机器的连接请求。

解决方法:
#vi pg_hba.conf
添加
local database            user                                       password
host  database            user              0.0.0.0/0           password
host  database            user              ::1/0                  password

原因有两种:

   原因1:postgresql.conf 的 listen_addresses 为缺省值'localhost'。

              如果改为'*',表示从本服务器的所有网卡地址监听外部请求,此时可以接受外部来的请求。

   原因2:pg_hba.conf 中没有允许 此机器的ip/user/database 连接请求的行设定。

 

错误类型2:

[postgres@cent6 pgsql]$ ./bin/psql -h 192.168.246.134 -p 5432 psql: could not connect to server: No route to host
Is the server running on host "192.168.246.134" and accepting
TCP/IP connections on port 5432?
[postgres@cent6 pgsql]$

这时,可能Ping是可以ping通,原因一般是服务器端或者客户端机器上设了防火墙,封堵了5432端口。

事实上,此时用 telnet ip 5432 去看,同样会得到 No route to host 的信息。

[postgres@cent6 pgsql]$ telnet 192.168.246.134 5432
Trying 192.168.246.134...
telnet: connect to address 192.168.246.134: No route to host
[postgres@cent6 pgsql]$

 

[作者 高健@博客园  luckyjackgao@gmail.com] 
回到上一级页面:PostgreSQL基础知识与基本操作索引页    回到顶级页面:PostgreSQL索引页 磨砺技术珠矶,践行数据之道,追求卓越价值

编辑:操作系统 本文来源:无法联接到服务器

关键词:

  • 上一篇:没有了
  • 下一篇:没有了