I just created a google cloud postgres with very basic authorization by whitelist the ip.
Google Cloud Auhtorization
I successfully connected to the google cloud postgres (35.240.xx.xx) from my home (139.193.xx.xx) using pgadmin and successfully created tables and inserted initial ddl.
pgadmin
When I want to use it in the shared hosting (119.81.xx.xx) that hosts laravel php application, I changed it in the .env file as below.
DB_CONNECTION=pgsql
DB_HOST=35.240.xx.xx
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=[google cloud password here]
But it didn't connect when I run the website with laravel.log as below.
[2018-07-12] ERROR: SQLSTATE[08006] [7] could not connect to server:
Connection refused Is the server running on host "35.240.xx.xx" and
accepting TCP/IP connections on port 5432? {"exception":"[object]
(PDOException(code: 7): SQLSTATE[08006] [7] could not connect to
server: Connection refused
Can anyone help me? Thanks.
It turns out that the shared hosting needs to also whitelist google cloud external ip address. It's working now.
Related
I try to connect my Laravel project into my local development environment to Google Cloud SQL (MySQL).
For this, I connected from my OSX Terminal with the Cloud SQL-Proxyclient to the remote database with port 3307.
I can connect with my MySQL Workbench to the remote database, and I can see/change tables, ...
Into my Laravel project into .env I changed the settings:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
DB_DATABASE=mydatabasename
DB_USERNAME=mydatabaseusername
DB_PASSWORD=mydatabasepassword
When I open my project into the browser, into terminal I can't see, that something tries to use the connection.
Into the browser I get an error message:
SQLSTATE[HY000] [2002] No such file or directory (2002)
I think, the project can't connect to the remote database
How can I solve this problem?
Thanks for help!
While the Cloud SQL Proxy connects to your database on port 3307, you want to connect to the Cloud SQL proxy on port 3306 (this is the default mysql port). You can also specify a custom port by updating the instances argument:
./cloud_sql_proxy -instances=my-project:us-central1:sql-inst=tcp:3306 &
I added now the public IP address of the server, and I added my local IP address to allowed IP adresses for the MySQL server. Now it works.
Make sure you have config for right DB_HOST. Let get an IPv4 Read this for more informations:
https://cloud.google.com/sql/docs/mysql/connect-external-app#appaccessIP
I have launched an AWS RDS with Oracle 11g (on port 1521).
Tried to connect using Oracle SQL developer. While testing the connection, getting the following error..
Error:
Status : Failure -Test failed: IO Error: An existing connection was forcibly closed by the remote host, connect lapse 0 ms., Authentication lapse 0 ms.
Explored various options and even opened up the windows outbound port from my local laptop to 1521 port. Nothing helped so far a week.
Found a solution..
Just launched another windows instance in AWS and modified security groups to make it secure access.
Security Group changes:
Opened the 1521 port of AWS RDS Oracle to the new windows instance
alone
Windows instance is restricted to only from office public IP.
This does not solve the real problem. However, this solves my purpose..
Thank you all..
i'm trying to access my localhost via ngrok, and my project is Laravel 5.3
The connection to http://****.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:8000.
how can i solve this issue ?
Kindly check if you tunnel same port which is used by your application like 8000.
I have created an ec2 instance and followed all steps according to AWS documentation, But I am unable to connect to database from the php files in html folder. Below is the error
Warning: mysqli_connect(): (HY000/1130): Host
'ip-172-31-28-115.us-west-2.compute.internal' is not allowed to
connect to this MySQL server in /var/www/html/test/test.php on line 11
Unable to connect to MySQL
The Php files are not getting connected to the database that is created on instance.
Note: I also tried creating new user and granted privileges to the new user but no luck!
It would be great if you can assist us through problem, since we have already spent lot of time experimenting on this.
Things to check for MySQL connection:
--/etc/my.cnf to ensure that listening on the right port(s) ip(s). 3306 default.
--Open port 3306 in AWS to ensure that client can access
--Grant privs on database to user that is connecting.
--Examine mysql logs and apache error logs for errors.
can you try running this? I think it has to do with permissions.
GRANT ALL PRIVILEGES ON . TO 'root'#'%';
FLUSH PRIVILEGES;
Hi again i want to connect to cleardb instance in heroku i take hostname and credentials from heroku config vars in CLEAR_DATABASE_URL but i am getting the following error
ERROR 2003 (HY000): Can't connect to MySQL server on 'us-cdbr-east-06.cleardb.net' (111)
im trying to connect in this way
mysql -u username -p -h us-cdbr-east-06.cleardb.net
any idea why i am getting 111 error?
thanks for your time
Error fixed thanks the help from cleardb support team, here support answer
Hi there,
Thanks for reaching out. You may want to check with your local network
administrator and/or ISP to ensure that you are allowed to access
remote resources that run on TCP 3306. It is possible that this port
has been blocked from your local network and/or machine. To be clear,
we performed a connection test on this database and found that it is
operating normally, so the next diagnostic step is to check your local
connectivity to remote MySQL databases.
Hope this helps,
member team