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
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 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
i am using openshift free tier (3 gears). My scalable app uses PHP and MySQL. But unavailability of phpMyAdmin credentials for 3 gears scalable app it's difficult for me to access Mysql table entries. My question is can port forward feature of Openshift is used to access openshift Mysql via locally installed wamp phpMyAdmin.
Yes, it is possible to use port forwarding to access your OpenShift database from your locally installed PhpMyAdmin.
First, make sure you have the Redhat Client Tools (RHC) installed on your computer. If you haven't, download them here: https://www.openshift.com/developers/rhc-client-tools-install .
In order to connect via SSH, you will need a public/private key pair. Again RHC can automate most of this for you when you run rhc setup. The application will ask for your credentials, optionally create an SSH key for you and upload it to your cartridges. Make sure to protect your SSH key with a secure password. This process is described in more detail at https://www.openshift.com/developers/remote-access .
You will need a SSH client. OpenShift recommends Putty for Windows users; detailed setup instructions can be found at https://www.openshift.com/page/install-and-setup-putty-ssh-client-for-windows . In addition I would recommend to install OpenSSH from Cygwin, as this makes it easier to forward the port to your database later on.
Use Putty and your SSH key to connect to your server via SSH. Once you are at the shell, type env to view a list of environment variables on the server. Look for the variables that end with _DB_HOST, _DB_PORT, _DB_USERNAME and _DB_PASSWORD and make a note of their values on your Windows machine. The names and meanings of all of these environment variables are described at https://access.redhat.com/site/documentation/en-US/OpenShift_Online/2.0/html/User_Guide/Database_Environment_Variables.html .
To forward the port, use Cygwin's ssh command. For example:
ssh -f user#my-app.openshift.com -L 3307:DB_HOST:3306 -N
You will have to replace user with your OpenShift username, my-app.openshift.com with your public OpenShift hostname and DB_HOST with the IP address from the ..._DB_HOST environment variable that you looked up above. If this command succeeds, you should now have a tunnel from your local port 3307 to the MySQL server at OpenShift. Thus, you can create a new database connection in PhpMyAdmin's configuration with 127.0.0.1 as the server, 3307 as the port and your credentials, which you got when running the env command via SSH.
Before you open the session with Putty, go to the Connection-->SSH-->Tunneling.
There add a port, for example, 3333. And set as destination the url of your remote mysql server and port, for example: 324324343455435435-yourservices.rhcloud.com:44351. Click on the "Add" button. Save your session and connect.
Once connected you can use whatever the client and connect to localhost on the port 3333 with the user, password and database name given by the env vars as the other guys said.
I connect with Toad for Mysql with no problems.
You can use the rhc port-forward command, similar to what i described here: OpenShift: How to connect to postgresql from my PC
instead of phpmyadmin.SQLyog from webyog has ssh tunneling option. which work fine for remote accessing openshift mysql
You can add this cartridge to have phpMyAdmin support in scalable apps:
https://github.com/arielscarpinelli/openshift-scalable-phpmyadmin
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 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.