PGAdmin: Not connected to the server or the connection to the server has been closed

China☆狼群 提交于 2020-01-13 07:42:26

问题


i got this problem with postgreSQL, when i do a simple query of anything (CRUD), sometimes it works and almost always shows this message:

Not connected to the server or the connection to the server has been closed.

I don't know how to solve it and it started to irritate me, anyone know how to fix it?

UPDATE 1

I have been searching and it seems the pgadmin4 the problem (it seems because it's not 100% developed yet), i have been using pgadmin3 and that error doesn't show up.


回答1:


The reason this happened for me was a syntax error in the query. Check your syntax and try again, maybe this suffices




回答2:


This issue has been fixed.

Upgrade to pgAdmin4 version 2.0. https://www.pgadmin.org/download/




回答3:


I have similiar problem before, im using postgre 9.6.1-1 I can do select without condition (ex: select * from foodtable) and i can do insert too.. But if i do select or edit or delete using a condition (ex: select * from foodtable where taste='sweet') the output is like your

Not connected to the server or the connection to the server has been closed.

I try reinstall (After uninstall delete all leftover data) and delete C:\Users\yourUserName\AppData\Roaming\pgAdmin (delete all data inside pgAdmin Folder) And its works

Update-> Your table name and field name must lowercase




回答4:


solution is:

select the database where you lost the connection.

then on the right hand side select SQL

For example in the picture (shopdb) is the db where I lost the connection to.

After that PgAdmin will ask you if you would like to reconnect to this database... click ok

you will notice a message retreiving data from the server




回答5:


Can you run & provide output of these sql queries from pgAdmin4?

1) SHOW SERVER_ENCODING;
2) SHOW CLIENT_ENCODING;

And what is the encoding set for your current database connection on which you are trying to run query (Right click on your database, click on Properties > Definition Tab > Check Encoding, Collation & Character type) ?

I'm suspecting you are facing issues due to encoding.




回答6:


Change the versión of pgAdmin, use pgAdmin 3, its a problem frequently between Windows 10 and pgAdmin4.




回答7:


just change the column name and run the query , it worked for me.

my column name was timestamp, it conflicted with datatype so i changed timestamp by _timestamp




回答8:


I solved this. I pressed F7 or Explain in drop-down list near the Execute button. Then I saw where exactly the trouble was. pgAdmin4 didn`t like the name of my column. Then I went to problem column and renamed it.




回答9:


I have same problem but i can create DB and table successful and my version is: window10 pro x64 9.5 (X86)

pgAdmin4

after i change to 9.4 (X86)+ pgAdmin3 is no more error.. and the table i create by 9.5 can be use(insert data) in pgAdmin3




回答10:


I was getting this error when running a long series of queries in a transaction. Then when I ran them separately, it didn't loose the connection. Still no idea why it actually happens...




回答11:


Juuuuust in case someone googled this post like i did. If you have JSON column AND you want to see ANY result in pgAdmin, cast JSON into VARCHAR like

SELECT id, metadata::VARCHAR FROM data_table; 

It doesn't matter if content is NULL or not, JSON doesn't work. Maybe there are other types or values that can't be parsed by pgAdmin as well.

Note: you can still insert values and recieve them after cast, so the problem is on JS side (put one more coin into your "Hate JS" jar).




回答12:


We have just experienced this on a standalone windows machine.

After reinstalling things and looking everywhere (logs, running psql in shell - all was good) then we found out that it was an older firefox that was the culprit.

So - please ensure that your browser is up to date :-)




回答13:


I am using the pgadmin version 4.6 which is the current release as for now.

I could only solve the problem by running query inside

    DO $$ ... BEGIN ... END $$;

block.

In case anyone still looking for an answer like me.



来源:https://stackoverflow.com/questions/41266659/pgadmin-not-connected-to-the-server-or-the-connection-to-the-server-has-been-cl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!