heroku postgresql could not connect to server: Connection timed out - postgresql

I'm trying to connect to postgres database in heroku using heroku pg:psql postgresql-rigid-33416 --app murmuring-ocean-62645, however I got this message
--> Connecting to postgresql-rigid-33416
psql: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "ec2-50-17-225-140.compute-1.amazonaws.com" (50.17.225.140) and accepting
TCP/IP connections on port 5432?
I have tried to turn off my firewall but the problem persists. Any idea how to solve this?
EDIT:
heroku version
heroku/7.16.0 win32-x64 node-v10.10.0
heroku pg:info
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 10.5
Created: 2018-10-09 14:03 UTC
Data Size: 7.6 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Add-on: postgresql-rigid-33416

In case someone else has this issue. I had same problem. I had to lower my network security by changing my Firewall Level on my local compter to 'Low' and it works.

Related

Postgres: "Failed to load sql modules into the database cluster" and other errors

I run Windows and I am trying to install postgres, but I can't get it to work. During installation, I get the error:
Failed to load sql modules into the database cluster
When I try to access the server in pgadmin or via SQL Shell, I get the error:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? 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 have found a log in the data-folder saying:
2021-04-08 14:53:44.315 CEST [11088] LOG: starting PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit
2021-04-08 14:53:44.321 CEST [11088] LOG: could not listen on IPv6 address "::": Permission denied
2021-04-08 14:53:44.326 CEST [11088] LOG: could not listen on IPv4 address "0.0.0.0": Permission denied
2021-04-08 14:53:44.327 CEST [11088] WARNING: could not create listen socket for "*"
2021-04-08 14:53:44.328 CEST [11088] FATAL: could not create any TCP/IP sockets
2021-04-08 14:53:44.331 CEST [11088] LOG: database system is shut down
Can someone please help me?
I had the same issue and followed different tips and tricks available on the internet but nothing worked.
I fixed that issue by following these steps:
First disable antivirus for an hour
Create a folder in either C drive or D drive and give full permission to User
Then again install a fresh application. If you have already installed then uninstall that and install from starting.
Make sure to choose that folder only at the time of installation

MacOS Catalina Wont connect to MONGODB Server on Google Compute Engine

I have a problems on my Macbook 15" Catalina to access Mongodb run in docker compute engine. If i use other laptop connection work well without error or with other os like ubuntu or windows that no problems. Cant connect just in my macbook 15" with os Catalina.
Error on mongo command :
▶mongo [PublicIP-VMInstance]:[PortMongo]/admin -u username -p password
MongoDB shell version v3.6.14
connecting to: mongodb://[PublicIP-VMInstance]:[PortMongo]/admin?gssapiServiceName=mongodb
2019-11-23T18:22:30.975+0700 I NETWORK [thread1] Socket recv() Connection reset by peer [PublicIP-VMInstance]:[PortMongo]
2019-11-23T18:22:30.975+0700 I NETWORK [thread1] SocketException: remote: (NONE):0 error: SocketException socket exception [RECV_ERROR] server [[PublicIP-VMInstance]:[PortMongo]]
2019-11-23T18:22:30.975+0700 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '[PublicIP-VMInstance]:[PortMongo]' :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
exception: connect failed
show error if i use --ssl flag :
▶mongo [PublicIP-VMInstance]:[PortMongo]/admin -u username -p password --ssl --verbose
MongoDB shell version v3.6.14
connecting to: mongodb://[PublicIP-VMInstance]:[PortMongo]/admin?gssapiServiceName=mongodb
2019-11-23T11:47:19.836+0700 D NETWORK [thread1] creating new connection to:[PublicIP-VMInstance]:[PortMongo]
2019-11-23T11:47:19.839+0700 I NETWORK [thread1] Socket recv() Connection reset by peer [PublicIP-VMInstance]:[PortMongo]
2019-11-23T11:47:19.839+0700 E QUERY [thread1] Error: socket exception [RECV_ERROR] for [PublicIP-VMInstance]:[PortMongo] :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
2019-11-23T11:47:19.839+0700 D - [thread1] User Assertion: 12513:connect failed src/mongo/shell/shell_utils.cpp 279
2019-11-23T11:47:19.839+0700 I QUERY [thread1] MozJS GC prologue heap stats - total: 3447601 limit: 0
2019-11-23T11:47:19.840+0700 I QUERY [thread1] MozJS GC epilogue heap stats - total: 1641 limit: 0
2019-11-23T11:47:19.840+0700 I QUERY [thread1] MozJS GC prologue heap stats - total: 3937 limit: 0
2019-11-23T11:47:19.841+0700 I QUERY [thread1] MozJS GC epilogue heap stats - total: 9 limit: 0
2019-11-23T11:47:19.841+0700 D - [main] User Assertion: 12513:connect failed src/mongo/scripting/mozjs/proxyscope.cpp 302
exception: connect failed
If use GUI Client like NoSQLBooster show error :
12:53:53.307 *** Starting MongoClient.connect ***
{"options":{"appname":"NoSQLBoosterV5.2.7_125336.468","autoReconnect":true,"keepAlive":60000,"poolSize":0,"promoteLongs":false,"promoteValues":false,"reconnectTries":172800,"socketTimeoutMS":0,"sslValidate":false,"useNewUrlParser":true},"uri":"mongodb://username:******#IPPublic-VMInstance:PORTMONGO?authSource=admin"}
12:53:53.311 *** Connect Error ***
{"errorLabels":["TransientTransactionError"],"message":"failed to connect to server [IPPublic-VMInstance:PORTMONGO] on first connect [MongoNetworkError: read ECONNRESET]","name":"MongoNetworkError","stack":"MongoNetworkError: failed to connect to server [IPPublic-VMInstance:PORTMONGO] on first connect [MongoNetworkError: read ECONNRESET]\n at Pool.<anonymous> (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/topologies/server.js:431:11)\n at Pool.emit (events.js:182:13)\n at connect (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/pool.js:557:14)\n at callback (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:109:5)\n at runCommand (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:129:7)\n at Connection.errorHandler (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connect.js:321:5)\n at Object.onceWrapper (events.js:273:13)\n at Connection.emit (events.js:182:13)\n at Socket.<anonymous> (/Applications/NoSQLBooster for MongoDB.app/Contents/Resources/app.asar/node_modules/mongodb-core/lib/connection/connection.js:321:10)\n at Object.onceWrapper (events.js:273:13)\n at Socket.emit (events.js:182:13)\n at emitErrorNT (internal/streams/destroy.js:82:8)\n at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)\n at process._tickCallback (internal/process/next_tick.js:63:19)"}
I have try with this tutorial :
openssl problems
https://community.exploratory.io/t/mongodb-ssl-connection-error-on-mac-os-x/832 [ still not working ]
use --ssl but in other laptop work well without this options
Apple has made TLS requirements stricter in Catalina. I have a similar case where the connection from Catalina fails using the mongo cli client. I couldn't find statements about changes in behavior of SSL specifically (which I am using). They may have changed something they didn't communicate.
About Catalina TLS changes: https://support.apple.com/en-us/HT210176
If I run a VM Ubuntu on Catalina, I'm able to connect from there. Also macs with Mojave can connect just fine using the same certificates, keys, and network.
Below is the error I'm seeing. It's slightly different to yours but also something that only happens on Catalina.
mongo --host myhost.com --ssl --sslCAFile ca.pem --sslPEMKeyFile client.pem -u myuser -p
W CONTROL [main] Option: ssl is deprecated. Please use tls instead.
W CONTROL [main] Option: sslPEMKeyFile is deprecated. Please use tlsCertificateKeyFile instead.
W CONTROL [main] Option: sslCAFile is deprecated. Please use tlsCAFile instead.
MongoDB shell version v4.2.1
Enter password:
connecting to: mongodb://myhost.com:27017/?compressors=disabled&gssapiServiceName=mongodb
E NETWORK [js] SSL peer certificate validation failed: Certificate trust failure: Host name mismatch; connection rejected
E QUERY [js] Error: couldn't connect to server myhost.com:27017, connection attempt failed: SSLHandshakeFailed:
SSL peer certificate validation failed: Certificate trust failure: Host name mismatch; connection rejected :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
F - [main] exception: connect failed
E - [main] exiting with code 1
I suggest you try generating new certificates that match Apple's new requirements if that's at all possible. Another thing you could try would be to run a Linux VM on your Mac and see if the connection works from there. If it does, I reckon it would narrow the issue down to the certificates themselves.
Update: Docker seems to be an alternative for the VM. Using a Docker container on a Mac with Catalina I can connect to mongo just fine.
Are you certain that PublicIP-VMInstance and PortMongo are resolving to IP addresses and a port by your mongo client? I'm running MacOS X 10.15.1 (Catalina) and Mongo client 4.2.1 and connections work perfectly for me using a connection string like this:
/opt/local/bin/mongo --ssl --sslAllowInvalidCertificates --host=mongo.mydomain.com:27017 -u mongoMatt -p dont*You*Wish

Couldn't connect to server apollo.modulusmongo.net

I'm trying to connect MongoDB database on modulus.io by referencing [this][1] tutorial.
I've registered with modules .io and received the database url. (Modulus provides the database URL you need and you can use mongoose.connect to connect to it)
i.e.
MONGO URI
mongodb://<user>:<pass>#apollo.modulusmongo.net:27017/wIp4otyd
MONGO CONSOLE
mongo apollo.modulusmongo.net:27017/wIp4otyd -u <user> -p <pass>
But when I'm trying to connect it through both node.js and console its showing me following error:
C:\mongodb\bin>mongo apollo.modulusmongo.net:27017/wIp4otyd -u <my_uname> -p <my_pwd>
2016-02-04T12:01:07.097+0530 I CONTROL [main] Hotfix KB2731284 or later update is installed, no need to zero-out data files
MongoDB shell version: 3.2.1
connecting to: apollo.modulusmongo.net:27017/wIp4otyd
2016-02-04T12:01:09.455+0530 W NETWORK [thread1] Failed to connect to 52.6.181.208:27017, reason: errno:10061 No connection could be made because the target ma
chine actively refused it.
2016-02-04T12:01:09.457+0530 E QUERY [thread1] Error: couldn't connect to server apollo.modulusmongo.net:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
Its connecting to local perfectly (mongoose.connect('mongodb://localhost/news');)
but refusing to modulus.io (mongoose.connect('mongodb://<my_uname>:<my_pwd>#apollo.modulusmongo.net:27017/wIp4otyd');)

hack for "mongo db connection refused due to blocked port errno 10061"

I m trying connect to my db in Mongolab:
>> mongo ds123456.mongolab.com
MongoDB shell version: 2.6.1
connecting to: ds123456.mongolab.com/test
2014-12-16T14:13:41.738+0100 warning: Failed to connect to 54.74.247.101:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2014-12-16T14:13:41.741+0100 Error: couldn't connect to server ds123456.mongolab.com:27017 (54.74.247.101), connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed
I assume this question answers the first problem of access being blocked on this port.
The obvious solution is to contact the network admin. But I wonder if there is an alternative?
Thanks in advance.

Zend framework - connection to postgresql

I encountered troubles when trying to connect to postgresql database within Zend framework application. In my application.ini I use
resources.db.adapter = PDO_PGSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = testtest
resources.db.params.dbname = testdb
But when I run the application, I got an error message
Message: SQLSTATE[08006] [7] could not create socket: Address family not supported by protocol.
Could you please tell me what can be wrong?
Zend version 1.12.3., PostgreSQL version 9.0.7, PHP version 5.3.5.
Thanks, Marek .
localhost on your machine is (most likely) resolving to the IPv6 address of localhost (::1), but since the protocol/module used does not support IPv6 connections, your connection fails.
You could either;
Use 127.0.0.1 as a host instead, that will force a connection to the IPv4 localhost.
Remove the host line completely, that will force a connection via UNIX sockets.
I had similar problem:
PDOException: SQLSTATE[08006] [7] 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? in
lock_may_be_available() (line of /app/ctr/ctr
web/drupal/includes/lock.inc).
The problem was caused because of a full disk. and PostgreSQL DB blocked/froze.
Making some free space and restarting of PostgreSQL DB resolved my problem.