I am just now migrating an application from a standard dedicated server that I have onto AWS EC2.
I have also moved the database (MySQL) onto Amazon RDS.
Now I have an issue that I am pretty sure has to do with either PHP or Apache configuration.
On my dedicated server I can now reach the Amazon RDS database without a problem, but on the EC2-instance, using the exact same code I get this message:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on ....................eu-west-1.rds.amazonaws.com
I can reach the db-server both from Sequel Pro on my laptop, and from PHP on my other server.
I tried to put in the IP-address for the MySQL db on my other server, but same error message, so I am thinking there is some configuration either in Apache or PHP that I need to do?
It is a EC2 instance running Apache and PHP on CentOS.
Suggestions as to what configuration could be blocking this connection?
To anyone else who might have the same problem, run this in SSH, it worked for me:
setsebool -P httpd_can_network_connect=1
Tried successfully
setsebool -P httpd_can_network_connect=1
on RHEL image on EC2 and it was able to connect with AWS-RDS in the same VPC.
For more information see. This is a MUST step on RHEL
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Booleans-Configuring_Booleans.html
Related
I have two web application and Oracle servers.
Web application server has the following details:
Linux server (LAMP)
oci8
PHP 7.4
Oracle Database server has the following details:
Oracle 19C
I am trying to connect Web Application Server to Oracle Database Remote Server. When I try to connect with remote Oracle server as a result following error shows:
ERROR is ORA-12546: TNS:permission denied.
*Note: While this remote Oracle Database server is connecting successfully from Windows server (WAMP).
Is this the first running of the web application? Can you connect to the database from the system running your web application using sqlplus?
In my case was the firewall. I enabled one rule that forbade the connection with the server. I just disabled the rule and the error was gone.
Had a similar issue. Though i wasn't using LAMP. I had a manually configured apache-php setup. I had to run the command in the Linux server to allow apache to make network connections - apparently, SELinux prevents this by default.
setsebool -P httpd_can_network_connect on
after seeing this: https://stackoverflow.com/a/26349596/9914081 which can be of help too.
I need one help.I am unable to connect access mongodb remotely from localhost of my system using PHP. I am running mongoDB in ubuntu server using this 10.10.5.80 and i am trying to connect from my system localhost for that i used the following code.
$con=new MongoClient("mongodb://10.10.5.80:27017");
But unable to connect.I have already checked the whether that post is listening or not and its running in my ubuntu server.When i am pushing all my code to that particular ip(10.10.5.80) its working fine.Here i need to connect that remote mongoDB server from localhost.Please help me to resolve this issue.
Please check following things in order to diagnose the issue:
Try connecting remote mongodb server from mongo shell from your local machine:
mongo --host 10.10.5.80 --port 27017
If step 1 fails, try to check if the remote port 27017 is accessible from you local machine
telnet 10.10.5.80 27017
If both 1 and 2 fail, it confirms that the remote mongo server is not accessible from you server.
Make sure your remote mongodb server is not bind to only 127.0.0.1(default), if that's the case you need to comment out the line in mongod.conf and restart the service.
If your mongodb on hosted on cloud, then make sure there is a security group rule that allows your local machine to access the remote host.
You can check mongodb logs/ mogostats if your requests from local machine adding up connections
Server newbie here!
I have access to an amazon AWS server, and I have a php webservice on my localhost. The php is working properly on the webservice. The MySQL is set up on the server. However, I cannot connect to my server. I set up everything on the amazon AWS server by SSH-ing in to it and working from there. Is there a way to allow me to ssh into the server with my webservice?
Just to reiterate:
-My php script is at localhost/ ...
-My server is accessed by ssh and then on my localhost, it is hosted by amazon aws (default port 3306)
I attempted the process suggested by one user which was to enter the following into my terminal:
ssh -L 8080:127.0.0.1:3306 -f -C -q -N -i ./password.pem user#host.com
and then when I used mysqli connect I entered:
new mysqli('127.0.0.1:8080','root','mypassword');
Thanks so much for any assistance!
It sounds like you are trying to connect to your remote database from your local server (if I understand correctly). You want to double check your security groups in AWS that they are allowing your computers ip address to connect to the server instance / that port 3306 is open to your pc. If that is all set, then you should be able to connect to the instance using the public dns or elastic ip if it is an EC2 instance, or the endpoint if it is an RDS instance.
I have an amazon EC2 instance (redhat linux ) and a RDS (mysql 5.5 ). After stop /start EC2 instance. EC2's ip was changed and cannt connect RDS anymore. I can successfully connect RDS instance from command line. However, it is unable to connect from php script and give me this warning.
PHP Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on 'applicantdb.xr3x2xcale.eu-west-1.rds' (13)
It is working fine from my localhost and I can connect to localhost. It is really annoying and if somebody knows the solution. Please help me and I do really appreciate it.
Thanks layke , the problem solved
The solution was
It restricts Apache remote database connection as default. So our scripts work in command line (# php sqltest.php), and mysql can connect to server but when Apache is involved (calling a php script as web page) then it doesn't work.
Setting:
setsebool -P httpd_can_network_connect=1
You need to in your RDS Security group make sure that your Amazon EC2 security profile has access.
I am developing locally and connecting to a remote mysql server. I had been using IIS on my local machine (WinXP) but am now using Apache instead. Most of my PHP site is working correctly after the move to Apache.
But - when mysqli tries to connect to the remote db I get:
(HY000/2003): Can't connect to MySQL server on '...:**' (10060)
I know that the server is accepting connections from my IP because I am able to connect to the same server from my local machine using MySQL Workbench.
I also know that the db connection details I'm using with mysqli are correct because I was using the same details when running on IIS without problem, the only change that happened is that I moved from IIS to Apache.
This problem still exists when my local firewall is disabled.
I have very little experience with Apache, is there perhaps a config setting I've missed that prevents me from connecting out to a remote db, or something that is mangling/hiding reporting of my correct IP?
Thanks for any help, I'm clutching at straws here...
Error 10060 happens when the remote MySQL server does not respond.
It could be that connections to port 3306 on the remote machine are being blocked. It could be that the system hosting PHP/Apache has a software firewall that is blocking the outgoing connection, or that PHP/Apache is not permitted to open network connections by that firewall.