Client can't connect to RabbitMQ server on localhost - php
I installed fresh RabbitMQ 3.1.3 on ubuntu 12.04.2 LTS by apt-get, and try to start consumers on the same server, but I have connection problem:
[PhpAmqpLib\Exception\AMQPRuntimeException]
Error Connecting to server(113): No route to host
There is status of working server:
Status of node rabbit#ns1 ...
[{pid,2106},
{running_applications,[{rabbit,"RabbitMQ","3.1.3"},
{mnesia,"MNESIA CXC 138 12","4.5"},
{os_mon,"CPO CXC 138 46","2.2.7"},
{xmerl,"XML parser","1.2.10"},
{sasl,"SASL CXC 138 11","2.1.10"},
{stdlib,"ERTS CXC 138 10","1.17.5"},
{kernel,"ERTS CXC 138 10","2.14.5"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:30] [kernel-poll:true]\n"},
{memory,[{total,27728944},
{connection_procs,2704},
{queue_procs,5408},
{plugins,0},
{other_proc,9021680},
{mnesia,60016},
{mgmt_db,0},
{msg_index,31144},
{other_ets,770736},
{binary,1968},
{code,14560395},
{atom,1356081},
{other_system,1918812}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,1262847590},
{disk_free_limit,1000000000},
{disk_free,214706556928},
{file_descriptors,[{total_limit,924},
{total_used,3},
{sockets_limit,829},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,125}]},
{run_queue,0},
{uptime,1265}]
...done.
I don't have any limitations by iptables (ports):
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
And etc/hosts is OK.
127.0.0.1 localhost
{IP-ADDRESS} ns1.***.org ns1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Whay I'm doing wrong?
UPD:
sudo netstat -nlp | grep 5672 returns: tcp6 0 0 :::5672 :::* LISTEN 2106/beam.smp
From rabbitMQ logs:
=INFO REPORT==== 2-Jul-2013::16:05:11 ===
started TCP Listener on [::]:5672
=INFO REPORT==== 2-Jul-2013::16:05:11 ===
Server startup complete; 0 plugins started.
=INFO REPORT==== 2-Jul-2013::16:35:04 ===
accepting AMQP connection <0.1130.0> (127.0.0.1:44112 -> 127.0.0.1:5672)
=ERROR REPORT==== 2-Jul-2013::16:35:14 ===
closing AMQP connection <0.1130.0> (127.0.0.1:44112 -> 127.0.0.1:5672):
{handshake_timeout,handshake}
I tried to change localhost to ip6-localhost and sometimes when try to starting consumer, it returns:
[PhpAmqpLib\Exception\AMQPRuntimeException]
Error Connecting to server(110): Connection timed out
UPD2 If I start consumer with debug flag and --env=prod (php .../app/console rabbitmq:consumer -w -d consumer_name), consumer starts and working.
If the necessary ports are not open on the rabbitmq server, you get this "No route to host" error when the client tries to connect.
To fix it, make sure the ports are open, if not, open them:
sudo iptables -I INPUT -p tcp --dport 5672 --syn -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 5673 --syn -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 15672 --syn -j ACCEPT
This sets it on temporally. Set it permanently with your iptables.
sudo vi /etc/sysconfig/iptables
Then restart:
sudo service iptables restart
Problem was fixed with reconfiguring listen address from 0.0.0.0:5672 to 127.0.0.1:5672 and small security fixes in OS.
Related
Remote MySQL Server not responding
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.
Can't telnet to mysql on 3306 from other vps
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.
OSX: Failed to listen on localhost:80 (reason: Permission denied)
I have downloaded PhpStorm and set all the required configuration. When I try to run the project on port 80, I get this error. Failed to listen on localhost:80 (reason: Permission denied) And when I try to use any other ports like 8080 ,I get this error. Failed to listen on localhost:8080 (reason: Address already in use) I have tried several different random ports. But I get this already in use error all the time. I have xampp installed. And when I try to run the url in browser with port , it works fine. The problem is that it isn't working on PhpStorm. I am stuck.
The errors description are very clear: The error: Failed to listen on localhost:80 (reason: Permission denied) You really don't have permission to use this port; so you need to change your user or use sudo to run your application. and the error: Failed to listen on localhost:8080 (reason: Address already in use) The address that you are trying to use localhost:8080 is already in use by other processes/software. Normally, if you change the port will solve the problem: (eg. 9090). But, if you want to know which program is using the port 80 in Unix (Mac OSX, Linux), you can use the lsof command: To do this: In the terminal, you need to use: sudo lsof -i :80 That will result something like this: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 82 root 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN) httpd 226 _www 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN) On this result, we can see that the /usr/sbin/httpd is listening on port 80 on my machine, which is the Apache server. To know the details of the process that is listening on port 80 you can use the ps command: ps u PID_of_target_process that will return a result similar to this: USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 82 0.0 0.0 2463324 4248 ?? Ss 9:48AM 0:00.93 /usr/sbin/httpd -D FOREGROUND To kill the process by the PID you can use the kill command, like the following: sudo kill -KILL PID_of_target_process After you kill the process the port will be available again.
The PHPStorm / Intellij built-in web server listens on port 63342 by default. https://confluence.jetbrains.com/display/PhpStorm/Using+the+Built-in+Webserver+in+PhpStorm You can set the port in the Run/Debug Configurations under PHP Built-in Web Server:
Stop your Apache server from XAMPP. Run your PHPStorm with ROOT privileges. If running PHPStorm is showing your the same error saying Failed to listen on localhost:8080 (reason: Address already in use). The ports 80 is used by any other application. Try checking your used ports with a free tools out there. Stop the process using port 80 and try running the phpstorm.
Xampp for Mac if you find you cannot get apache to run and you have no apache web server already running! ......in terminal type..... sudo apachectl stop ......then run...... sudo /Applications/XAMPP/xamppfiles/bin/apachectl start .....if you have a port not specified you need to go into applications/xampp/xamppfiles/etc/httpd.conf and on line 52 or 53 you have a ip or localhost you can set. adding a port number add :port number example 192.168.64.2:80 or localhost:80 save and run sudo /Applications/XAMPP/xamppfiles/bin/apachectl start }}}}}}}}}}}}}
Can't access MySQL remotely on my work development machine
Today I've been trying to access MySQL running on my remote work machine (Ubuntu), from my home machine (OSX), and I've had no success. On my work machine, I've checked the following: sudo netstat -ntlup | grep mysql gives tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 23692/mysqld and nmap tells me PORT STATE SERVICE 3306/tcp open mysql and in /etc/mysql/my.cnf I've set bind-address = 0.0.0.0 I've also run the following iptables rules: iptables -A INPUT -i lo -p tcp --dport 3306 -j ACCEPT iptables -A OUTPUT -o lo -p tcp --sport 3306 -j ACCEPT What else can I check? If there is some corporate network rule blocking my MySQL access, what could I check to find this? The only way I can make this work is ssh tunnelling: ssh -L 8080:localhost:3306 my_user_name#my_dev_machine_IP and then if I do mysql -h 127.0.0.1 --port=8080 -u root -p I can get in. If I close the ssh tunnel, then I can't log in via mysql, nor even via telnet remote_IP 3306. But this is no good for what I want, because I need the PHP code running on my local machine to be able to access the remote database. I've also (hopefully temporarily) opened up the access to the MySQL databases to all hosts/IP: GRANT ALL PRIVILEGES ON *.* TO 'application_username'#'%' FLUSH PRIVILEGES Any advice gratefully received!
Ubuntu has uwf - in some vps installations it is enabled by default. So, if it is, do sudo ufw allow 3306. I am writing this jsut in case you run nmap from your work machine. If nmap shows that result run from your mac, then this does not apply.
Port 8080 not accessible on Linux server
I started local server using php on my server . (Trying to work on port 8080/8283 . Anyone of them will do .) php -S 0.0.0.0 8283 -t testServer/ using curl localhost:8283 I am able to get the result of the index.php file but when I access it using my server ip I am not able to access that port . Any when I do netstat -tuplen . I can see that port as well . How can I make port 8283 available through http request ? I asked this question here but not much help . I have used this # /sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8283 -j ACCEPT # service iptables save # service iptables restart and still it did not work And this is output from telnet on my server telnet XX.XX.X.XXX 8283 Trying XX.XX.X.XXX... Connected to XX.XX.X.XXX. Escape character is '^]'. GET / HTTP/0.9 200 OK Connection: close X-Powered-By: PHP/5.5.19 Content-type: text/html Hello World !Connection closed by foreign host. this one is from my PC telnet XX.XX.X.XXX 8283 Trying XX.XX.X.XXX... telnet: Unable to connect to remote host: No route to host NMAP Result sudo nmap -p 8283 XX.XX.X.XXX Starting Nmap 5.21 ( http://nmap.org ) at 2015-02-04 19:18 IST Nmap scan report for srv1.domain.com (XX.XX.X.XXX) Host is up (0.035s latency). PORT STATE SERVICE 8283/tcp filtered unknown Nmap done: 1 IP address (1 host up) scanned in 0.37 seconds IPTABLES OUTPUT /sbin/iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8282 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8283 state NEW,ESTABLISHED Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
try php -S 0.0.0.0 8080 -t testServer/ by use localhost you will bound just 127.0.0.1 address: that address is not reachable by other address instead of localhost or localhost.localdomin. Now by use 0.0.0.0 you will bound all your interfaces. Alternatively you can use your host address where you want expose the service.
You do not have to use localhost you have to use your external ip address: php -S <ip-address> 8080 -t testServer/ localhost is mapped on ip 127.0.0.1 so it is only available from yor server.
You're explicitly binding to localhost. If you want to bind to a different IP address, then specify it instead of localhost (or use 0.0.0.0 for all network interfaces).