My vps system verion is Ubuntu 16.04.1 x64.
Mysql version is 5.5.48
I have tried various methods to support 3306.
I have updated "etc/my.cnf" file to commented "'skip-networking" and have the "bind-address" to be 0.0.0.0;
and I use "netstat -an | grep 3306" to check the port status, I got the result:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:35498 127.0.0.1:3306 TIME_WAIT
I had shut down my firewall, when I type "ufw status", I got:
Status: Inactive
But after all the step and reboot my vps, I type "telnet 128.XXX.XXX.27 3306" on other vps, I got:
telnet: connect to address 128.XXX.XXX.27: Operation timed out
But the strange thing is when I type "telnet localhost 3306" on the local vps, it works fine.
So What could be possible problems? I could provide more details you want.
Thanks a lot!
I solved it.
It was a problem with the firewall.
Although I turned off the firewall, but the rule of the iptables are still affect all network requests, and use "iptables -L", I found that:
DROP tcp -- anywhere anywhere tcp dpt:mysql
The beginning is "DROP", and the end is "mysql".
After I removed this line, everything is fine.
Related
I have set up a raspberry PI 4 with Ubuntu. Apache, PHP, mysql and phpmyadmin are installed and working fine. So when I am trying to connect from another network with my windows device over MySQL Workbench there is an error occuring.
error
Checked: port forwarding on port 80 is open. checked binding ip in mysqld.conf (maybe I made a mistake there) when I try to change the port in this configuration file to 80 and restart "sudo service mysql restart" this error occure "Job for mysql.service failed because the control process exited with error code"
So maybe mysql is not listening to port 80. I have checked sudo lsof -i :80. Only found records from apache listening to port 80.
I am trying for three days now to connect to the database.
Thank you for your help guys!
By default, mysql listens on port 3306, so if you are trying to connect directly to mysql, that could be the issue. Port 80 and 443 are for http/https respectively.
You can't set the port to port 80 because apache needs that port to listen for http requests.
Try setting the port back to 3306 on the mysql host machine and seeing if that works. You may also need to open that port on the host machine as well.
The title might make this seem like a duplicate of some existing questions here on SO, but its kind of not in a way, in my opinion.
8140863, 30617357, 27749691
But I can't for the life of me make the answers to these threads work, instead of asking questions on those threads, I would like to create my own question, I'd like to discuss my setup and then my problem, and then what I've tried
My server setup is this, I have a local(an actual physical machine) and a VPS I'm renting, both are running at Centos7.x, PostgreSQL10, Php 7.x, and Python-2.x, BOTH can ping and ssh each other through a VPN just fine.
Both can connect to their own respective databases just fine through PHP, Python, PSQL Terminal
On my VPS Server, I can connect to my Local Server's PostgreSQL database using Python(psycopg2), PHP(php-pgsql) and Terminal(psql) totally fine.
On my local server, I can connect to my VPS PostgreSQL using Python(psycopg2) and Terminal(psql) EXCEPT through PHP(php-pgsql)
Whenever I connect to VPS's PostgreSQL through PHP, I'm getting this error like everyone else
pg_connect(): Unable to connect to PostgreSQL server:
could not connect to server: Permission denied
Is the server running on host "123.456.0.789" and accepting TCP/IP connections on port 5432?
Here are what I've done.
On postgresql.conf set listen_address = "*" -- this is OK
Added pg_hba entries for both -- this is OK (python and terminal can connect on both)
Port 5432/tcp is both enabled and allowed -- this is OK
Selinux is disabled -- this is the answers for the thread referenced above, but it doesn't work for me even after reboot of course.
these are the result of my netstat
#netstat -na | grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
tcp6 0 94 ::1:55110 ::1:5432 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:55060 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:55110 ESTABLISHED
tcp6 12 0 ::1:5432 ::1:55108 ESTABLISHED
tcp6 0 12 ::1:55108 ::1:5432 ESTABLISHED
tcp6 0 0 ::1:55060 ::1:5432 ESTABLISHED
unix 2 [ ACC ] STREAM LISTENING 31102 /var/run/postgresql/.s.PGSQL.5432
unix 2 [ ACC ] STREAM LISTENING 31104 /tmp/.s.PGSQL.5432
iptables
#iptables-save | grep 5432
-A IN_public_allow -p tcp -m tcp --dport 5432 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT
getenforce
#getenforce
Disabled
Selinux
#/usr/sbin/sestatus | grep SELinux
SELinux status: disabled
#sudo setsebool -P httpd_can_network_connect_db 1
setsebool: SELinux is disabled.
postgresql.conf
listen_addresses = '*'
port = 5432
pg_hba.conf (i just changed the ip for posting here) I tried using trust, but its still the same
# "local" is for Unix domain socket connections only
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 password
host all all 123.456.0.1/32 password
host all all 123.456.0.11/32 password
host all all 123.456.0.20/32 password
# IPv6 local connections:
host all all ::1/128 password
edit start: My PHP pg_connect code (I just changed the IP just for this post, but it points to the VPS IP)
$pgcon = pg_connect("dbname=database1 user=some_user password=some_password host=123.456.0.789");
edit end : ==
I would like to emphasize that BOTH servers can connect on each others and their own PostgreSQL database through other means, with the exception of my Local Server, it couldn't connect to VPS PostgreSQL using PHP.
VPS To Self(localhost connection)
VPS to Self via PHP is OK
VPS to Self via Python is OK
VPS to Self via PSQL(Terminal) is OK
VPS To Local Server(Connecting using Local Server's VPN IP)
VPS to Local Server via PHP is OK
VPS to Local Server via Python is OK
VPS to Local Server via PSQL(Terminal) is OK
Local Server to Self(localhost connection)
Local Server to Self via PHP is OK
Local Server to Self via Python is OK
Local Server to Self via PSQL(Terminal) is OK
Local Server to VPS(Connecting using VPS's IP by VPN and Public IP)
Local Server to VPS via Python is OK
Local Server to VPS via PSQL(Terminal) is OK
Local Server to VPS via PHP Is NOT OK
I'm really sorry for the long thread, I wanted to give as much information as I can.
Let's split error by types. I'd made several tests with your case and what I found:
If we mess with connection parameters (i.e. wrong port, or IP address) we get the error "could not connect to server: Connection refused" or "Operation timed out
Is the server running on host "128.0.0.1" and accepting")
If we mess with credentials, we get the error "FATAL: password authentication failed for user ..."
Permission denied can be thrown only if you have not permissions to open a TCP connection from your PHP library.
Pls, double-check if you disable SElinux on your Local Server as for me, this is still the closest workaround for your problem.
I'm having issues connecting to my AWS EC2 Server holding a MySQL Server.
Here's my Response from mysqli_connect
p#xxx.com [~/app]# php checkmysqlremote.php
Error: Unable to connect to MySQL.
Debugging errno: 2002
Debugging error: Connection refused
Here's my netstat -tuplen on the EC2 Server containing the MySQL Server
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 999 20299 1378/mysqld
As you can see its binding to the 0.0.0.0 address correctly.
I enabled the 3306 port in inbound rules for EC2.
on the server making the request handshake, I ran:
curl -s example.com:3306 >/dev/null && echo Success. || echo Fail.
which resulted in Fail.
I also ran it on the local server instance and it responded with Success.
I also ran nmap on the server making the handshake,
nmap -p 3306 example.com
Nmap scan report for example.com (1.1.1.1)
Host is up (0.048s latency).
PORT STATE SERVICE
3306/tcp filtered mysql
Nmap done: 1 IP address (1 host up) scanned in 2.03 seconds
Lastly, I tried adding the following rules in iptables:
iptables -A INPUT -i eth0 -s "example.com" -p tcp --destination-port 3306 -j ACCEPT
and
sudo iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
I don't know what to do at this point.
UPDATE
I tried pinging the EC2 server from the remote server and it did not return anything. At this point i think the issue is with EC2.
Try adding the follwing GRANT to your user:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'ipadress'
Sounds like the port might not be getting forwarded correctly? One thing to try might be to put an Amazon Elastic Load Balancer in front of the instance. Then you can forward port 3306 for the MySQL connection.
I have a running RabbitMQ cluster on 2 machines, let's call them rmq1 and rmq2.
I am using a PHP driver to connect to the nodes. When i run the code from rmq1 or 2 and my host is localhost, the connection works. But when i try to connect from another node from across the network, the connection fails with the error below
[PhpAmqpLib\Exception\AMQPRuntimeException]
Error reading data. Received 0 instead of expected 7 bytes
I have verified my RabbitMQ is listening on all interfaces, like so :
sudo netstat -plunt | grep 5672
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 2749/beam.smp
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 2749/beam.smp
tcp6 0 0 :::5672 :::* LISTEN 2749/beam.smp
And i tried telnetting from the lan machine to host
telnet 192.168.0.40 5672
Trying 192.168.0.40...
Connected to 192.168.0.40.
Escape character is '^]'.
That works too. So what gives?
Most probably you are using guest login to connect to RabbitMQ server. Guest login can only works through localhost, you have to add another user with enough rights to access RabbitMQ other than localhost.
Refer: RabbitMQ Access Control
Wamp server icon in system tray indicates in orange color and i could not be able to connect.
When checking the apache services it displays the error as follows:
your port 80 is actually used by information not available (might be skype)
I even checked with the other programs that whether they are using the port 80. the answer is no and I have not installed skype/IIS on my machine.
I have followed what is mentioned in the following link also which is failure again. WAMP - Your port 80 is actually used - Error
i copied httpd.conf from another machine's wamp folder. stopped all services and restarted It was not working again.
Please any one help me on this to solve this.
To find out if something is using port 80 and what that thing is launch a command windows using 'Run as Administrator' and do :
netstat -aon | find ":80"
The result might look something like this
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 6948
TCP 192.168.2.11:52629 190.93.245.58:80 ESTABLISHED 6420
TCP 192.168.2.11:52630 198.252.206.16:80 ESTABLISHED 6420
TCP [::]:80 [::]:0 LISTENING 6948
The numbers at the end of each line are PID's so take the PID number from above and do
tasklist /fi "PID eq 6948"
You should see something like
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
httpd.exe 6948 Services 0 24,688 K
Although the program using port 80 may be different.
And thats the program that is using port 80, its Apache in my case.
Well, I once have this problem, and found the problem that apache server is NOT actually installed.
Try click on Apache->service in wamp's trasy icon. Click on "Install service". Cmd will be opened, press enter. Restart all service, and put it online.
Hope this helps.