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

40.3k views Asked by At

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.

14

There are 14 answers

2
Murtuza Z On

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.

0
Anil Sambasivan On

My operating system is windows 10. pgAdmin Version - 4.5

I was getting this error when executing scripts, downgrading to pgAdmin version 4.3 fixed the issue for me.

0
josedlujan On

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

1
S. Koshelnyk On

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.

1
Alexander Chandra On

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

0
林大為 On

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

4
lucidbrot On

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

1
Iqra Abdul Rauf On

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

0
WISAM On

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.

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

you will notice a message retreiving data from the server

0
iCpu On

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).

0
Laro88 On

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 :-)

4
Murtuza Z On

This issue has been fixed.

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

0
Momchill On

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...

0
gokaysatir On

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.