Cannot Add PgAdmin New Connection on Ubuntu 15.10 - postgresql

After install pgAdmin III from Ubuntu Software Center, I opened it and it required to add a connection to a server. So I filled in information as below:
Upon clicking on Ok Button, it showed the error message
Error connecting to the server: could not translate host name
"http://127.0.0.1" to address: Name or service not known
As message indicated, I thought the postgres service was not started. Therefore, I went on go terminal console and start service by entering sudo service postgresql start, but it returned Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
. What's wrong or missing for my pgAdmin III? I'm just using Ubuntu earlier and I have never this problem on windows. Thanks.

http://127.0.0.1 is more a URL, that field is looking for a host so simply remove the http:// to leave the localhost's IP address 127.0.0.1 or type localhost if that resolves to the correct address (it should, usually, via /etc/hosts or the like)
Also, Debian/Ubuntu tend to ship the database servers separately. For Ubuntu, the postgresql package (which requires postgresql-common) package should include /lib/systemd/system/postgresql.service therefore you should be able to sudo systemctl start postgresql
Do you have postgresql (as opposed to postgresql-client) installed?

Related

Cannot complete pgadmin4 setup. Apache web server

I've got problem with completing pgadmin4 installation thru sudo /usr/pgadmin4/bin/setup-web.sh command.
During this process instalator does not recognizing that Apache is running and asks me if I want to start it:
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? y
Then it just spits some errors:
Too few arguments.
Error enabling . Please check the systemd logs
Too few arguments.
Error starting . Please check the systemd logs
So far I havn't found where the logs are stored.
About my apache, I am quite sure that my server is running, because I can connect to it through browser, phpmyadmin is working properly, and service apache2 status returns * apache2 is running. By my understanding apache2 is just fancy word for httpd service, and there is no other service called simply apache.
PostgreSQL seems to work properly from command line, haven't tested if I can connect to it yet, but this shouldn't be the case right?
I am using
**PostgreSQL:** 12.5 (Ubuntu 12.5-0ubuntu0.20.04.1)
**Ubuntu:** Ubuntu 20.04 LTS
**Server:** Apache/2.4.41 (Ubuntu)
I had the same issue for Debian 10 and Ubuntu 20. The /usr/pgadmin4/bin/setup-web.sh script is using 'uname -a' which doesn't contain "Debian" identifier in the return string. Updating this to read /proc/version will allow APACHE to be specified as the Debian variant of apache2.
Change:
UNAME=$(uname -a)
To:
UNAME=$(cat /proc/version)
I had a similar problem with Ubuntu running inside WSL 2. Managed to resolve it by modifying the /usr/pgadmin4/bin/setup-web.sh script. I moved these lines outside of the conditional:
IS_DEBIAN=1
APACHE=apache2
This allowed the installation to progress beyond the Too few arguments. error. There was still an error however:
System has not been booted with systemd as init system (PID 1). Can't operate.
Error restarting apache2. Please check the systemd logs
I resolved this by running:
sudo service apache2 restart
After this I tried bringing up the admin page by visiting http://127.0.0.1/pgadmin4 from the Windows host. This still didn't work, and had to connect using the Ubuntu machine's ip address (you can find it out via ifconfig) which finally allowed me to see the login page.

pgadmin can't log in after update

Just updated pgadmin4 to version 4.8 and now it won't accept ssh tunnel password into server, I get the following error message:
Failed to decrypt the SSH tunnel password. Error: 'utf-8' codec can't decode byte 0x8c in position 0: invalid start byte
Is there a way around this, I can't restart the database server at this time.
In latest pgAdmin4 version they have increased the security of saved password by implementing master password feature, I think that is causing this issue, meantime you can rename pgadmin4.db to pgadmin4.db_OLD and restart pgAdmin4.
Note: You have to add the all the servers again.
---------- UPDATE ----------
It has been fixed now https://redmine.postgresql.org/issues/4320 and will be in 4.9.
You can try nightly builds though https://postgresql.org/ftp/pgadmin/pgadmin4/snapshots
This also happened for me moving from 4.8.2 for Ubuntu 18.10 to 4.8.2 for Ubuntu 19.04 (different installs). I was able to resolve this by restarting the postgres server with sudo systemctl restart postgresql
As said Murtuza Z, in https://redmine.postgresql.org/issues/4320, you can get fixed server_manager.py and replace it at (pgAdmin install dir)/web/pgadmin/utils/driver/psycopg2/server_manager.py, then restart the pgadmin server.
You can get server_manager.py:
It is attached in an issue info. < this worked for me.
Get from snapshots provided by Murtuza Z in same directory.

Can't connect Mongo shell to Mongo Atlas M0 using mongodb+srv

I am trying to connect to my MongoDB Atlas Cloud cluster via the mongo+srv connection like so:
mongo "mongodb+srv://cluster0-mhzdc.mongodb.net/test" --username myuser
I am getting this response:
DNSHostNotFound: Failed to look up service "_mongodb._tcp.cluster0-mhzdc.mongodb.net": Undefined error: 0
try 'mongo --help' for more information
I am using the following version of Mongo client:
mongo --version
MongoDB shell version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
I can't find any resolution online. Any ideas what's wrong? Is this a bug in the given version of the Mongo shell client?
It looks like bug 34117, still unresolved:
https://jira.mongodb.org/browse/SERVER-34117
To work around the bug check if you have a DNS resolver active on your notebook.
On windows:
ipconfig /displayDNS
to see the current DNS resolver cache.
You might even try to erase the cache with the command:
ipconfig /flushdns
and retry.
If you are working on linux ubuntu try the command:
named -v
to check if the DNS resolver software is already installed.
If not:
sudo apt update
sudo apt install bind9 bind9utils bind9-doc bind9-host
to install the needed packages, then start the service:
sudo systemctl start bind9
and retry.
On Mac OSX, the command is:
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
The same happens to me, but just after i change my internet provider. Before, i could connect to mongo atlas with no problem.
I guess this happens because the DNS resolver of my internet provider could not resolve the uri to connect to mongodb atlas.
The Solution ->
Change de DNS resolver on my PC:
Open the Control Panel.
Click View network status and tasks
Click Change adapter settings on the left portion of the window.
Double-click the icon for the Internet connection you're using.
Click the Properties button.
Click and highlight Internet Protocol Version 4 (TCP/IPv4) and click Properties.
If not already selected, select the Use the following DNS server addresses option.
Enter the new DNS addresses and click OK and close out of all other windows.
I used google public dns 8.8.8.8.
After that i could connect again with my mongo shell ou compass to mongo atlas.
Hope that helps someone..
I also had this problem with Comcast Xfinity. For those running Ubuntu 18.04 or similar, I had to edit (you'll need root permissions) the /etc/dhcp/dhclient.conf file, and add to following line:
supersede domain-name-servers 8.8.8.8, 8.8.4.4;
I hope this helps somebody, took me too long to figure it out. :-)
I spent lot of time to figure the out issue. after the change DNS it worked. thanks
Used google dns servers.
8.8.8.8
8.8.4.4

pg_hba.conf for Postgresql from Windows Anaconda

I've just installed Postgressql (9.5.4 vc14_0) and Psycopg2 (2.7.5 py36h74b6da3_0) and I'm trying to use them within my Anaconda environment on Windows 10.
Whenever I run psycopg2.connect("host=localhost user=postgres") in a python interpreter or just psql on the command line I get this error:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
I've looked at other Stackoverflow questions regarding this, some answers say to look into a pg_hba.conf file although I haven't be able to find any. Where can I find a pg_hba.conf file for my Postgresql in my Anaconda Environment for Windows? If I have to make one, what should go in it? I haven't seen another SO question that uses the same Postgresql-Anaconda-Windows setup that I'm using.
Also I've looked into services.msc but haven't seen a service regarding postgresql.
I just ran into this error as well. Similar to what you did, I followed the installation page, ran conda install -c anaconda postgresql and received the same error in your post.
I have used postgresql through direct installation before, in osx and as far as I can recall, you could just psql into the database once the installation is complete.
Maybe this isn't the case for anaconda installations. I overcame this by initializing a new database system in a new, empty folder. In my case, I created a new folder in "\AppData\Local\conda\"
-- Initialize the database system
pg_ctl init -D <path_to_your_database_system>
-- Start the database
C:/Users/kerwei/AppData/Local/Continuum/anaconda3/envs/py36/Library/bin/pg_ctl -D <path_to_your_database_system> -l logfile start
NOTE: After playing around with for awhile, I realized that once you exit the conda environment, the database instance gets terminated too - without properly shutting down. As I don't use it for production stuffs, it doesn't really bother me. However, further steps can be taken to include the database booting and shutting down during conda activate or conda deactivate to make it less cumbersome.

Starting a postgres SQL 9.6 Server on Amazon Linux returns unrecognized service

I am attempting to start a Postgres SQL server on amazon Linux using the command
sudo service postgresql start
I installed the server using this method. I have added it here for simplicity
sudo rpm -i https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
and then
sudo yum install postgresql96-server.x86_64
after which i did this to install the command line tools for postgres
sudo yum install postgresql96.x86_64 postgresql96-libs.x86_64
Any suggestions on how I can start the server ? I usually start the server using
the command
sudo service postgresql start
however its not working in this case as it says "Unrecognized service"
I then tried this
postgres -D /usr/local/pgsql/data
postgres: could not access directory "/usr/local/pgsql/data": No such file or directory. Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Having the same issue, or similar. May be I installed pgsql from source, don't remember. We could make our own service start files. How? Let's find out! >>RTFM<< starting with what we already know:
man service
which leads us to chkconfig(8), so
man chkconfig
and it gives us an option
chkconfig --add ${svcname}
to add a brand new service under a name we choose!
But before we do, we might actually want to check what's already there. With
service --status-all
we get a list of all known services and their run status. And I found "postmaster" in my list, and as you might know, the PostgreSQL master server to connect to used to be called "postmaster". Yet, when I try
service postmaster status
it also tells me it doesn't know such service. OK, forget it -- for now -- just let's move on with making our own! But I still want to peek what there is in run-level 3 (normal server run level). So I go
ls -1 /etc/rc.d/rc3.d |fgrep post
and there I find: "K36postgresql95"! So, accordingly our service name should be "postgresql95". Trying that:
service postgresql95 status
it says now "postmaster is stopped". Confusingly the name the service reports for itself both in service --status-all and when we individually inquire for it is different than the name used to actually address it in the service command. Good to know. Easy enough to search /etc/rc.d for the name of interest.
service postgresql95 start
now starts the service. And check with
psql -U ${pguser} ${pgdb}
and I find that working. So now all I need to do is enable that service at system boot to auto-start
chkconfig --levels 3 postgresql95 on
and that works, doesn't it?
PS: It doesn't matter that I happen to run version 9.5
I recently installed PostgreSQL 9.2.24 on Amazon Linux 2 and I had to initialize the database manually before being able to create ROLE and DATABASE as I normally would on Ubuntu.
// initialize database after installing with yum
$ sudo postgresql-setup initdb
// start
$ sudo systemctl start postgresql.service