The local port 3000 is not available (CentOS ,browser-sync, VSCode Remote SSH) - centos

I'm doing development with VSCode Remote SSH, where CentOS 7 is running.
I use BrowserSync to proxy remote URL, it was usually running on localhost:3000 and localhost:3001 (this is the default)
but some time ago after I played a little with VSCode extensions for this purpose I noticed, that VS Code Remote started to auto-forward ports 3000 and 3001 to some random ports like 581116 etc.
If I try to change 'Local address' on "ports" tab to 3000, I get error "the local port 3000 is not available'.
If I set up Browsersync to use ports 3002 and 3003 for example, VS Code forwards them as 3002 -> 3002, 3003 -> 3003, that is expected, but not with 3000 / 3001 anymore. I suspected that some unfinished process occupied this port, but I cannot detect any connected processes with sudo lsof -i -P -n and any other command I tried.
I tried also npx kill-port 3000, but this didn't help either.
What is happening and how can I claim my localhost:3000 back?

Related

Remote xDebug not connected to NetBeans, despite the xdebug and ssh-tunnel works?

I have a trouble with the connection from remote xDebug to local NetBeans debugger.
Synopsis:
Remote server: FreeBSD (shared hosting, no root), Apache/Nginx, PHP5.6.
I've installed and configured xdebug with following settings in php.ini:
[debug]
zend_extension="/home/USERNAME/usr/php/lib/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=localhost
xdebug.remote_port=9009
;xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="/home/USERNAME/logs/xdebug/xdebug.log"
xdebug.profiler_output_dir="/home/USERNAME/logs/xdebug/profiler/"
xdebug.trace_output_dir="/home/USERNAME/logs/xdebug/trace/"
USERNAME - is a real user name folder... in other words, the paths are correct, it is tested.
autostart - is just for now, until I will solve a problem.
phpinfo() tells me that xdebug installed successfully.
Local machine:
Windows XP, NetBeans, firewalls are off.
I have no a reserved IP, so I've created a reverse SSH-Tunnel via Putty:
R9009 - localhost:9009
Remote 9009 port forwards to local 9009, everything seems simple.
Next I went back to remote server and check the tunnel by netstat -a|grep 9009
tcp6 0 0 localhost.9009 *.* LISTEN
Ok, next I checked xDebug activity by refreshing my website page in my browser; due to autostart options any request should cause a xdebug data transmittion, and my test shown me that xdebug works well:
tcp4 0 0 nosorog.nichost..14107 localhost.9009 SYN_SENT
tcp6 0 0 localhost.9009 *.* LISTEN
Ok, xDebug tries to establish connection to localhost:9000, but nothing happens on my local machine...
xdebug's log contains the timeout message:
E: Time-out connecting to client. :-(
So, what I've tried:
First, I decided to re-check if ssh-tunnel works. I just ran simple python script-listener on local machine, and ssh -p 9009 localhost on remote server, and connection was successful.
Ok, tunnel works well.
BUT neither netbeans nor listener-script receive any connection when xdebug tries to establish connection.
UPD:
I've tried to establish connection with telnet or nc, and that was successfull too...
So at this moment:
if I try to connect from remote to local via ssh or telnet or netcat - connection is successfull (test script accepts connection, netbeans ignores (if I connect via ssh or telnet) or crashes (if i connect via netcat), but wireshark sees packets in both cases);
but if xDebug or test script with sock.connect(('localhost', 9009)) tries to connect - there are SYN_SENT port state and timeout erroron remote machine, and no reaction on local machine (just LISTEN at port 9009 and nothing at all in wireshark)
I guess the clue is what is the key difference between first and second cases?

Remote debugging tomcat with OpenShift

I am using openshift for my tomcat webapp. I am able to run the app but unable to debug it. As openshift starts tomcat in debug mode, I was expecting I'll be able to debug.
Host:
$OPENSHIFT_JBOSSEWS_IP
Value of this is 127.5.20.129 for me which I got from command:
rhc port-forward -a {appname}
Port:
$OPENSHIFT_JBOSSEWS_HTTP_PORT
Value is 8080 for me.
I tried above host/port. I tried port 8000 too but nothing works. I am unable to connect from eclipse remote debugger each time.
Please help.
You should read through the Developer Portal's pages on Port Forwarding (https://developers.openshift.com/en/managing-port-forwarding.html) to make sure that you are using it correctly. You will want to connect to your local loopback address: 127.0.0.1 along with the correct forwarded port once you have run the port-forwarding command.

I am unable to setup remote debugging for my Tomcat 6 web app on Ubuntu 12.04, can anyone help me?

I am unable to setup remote debugging for my Tomcat 6 web app on Ubuntu 12.04.
I have tried the solutions offered in the following related question:
Remote debugging Tomcat with Eclipse
The highest ranked solution says I should open catalina.sh and change the JPDA_OPTS variable to:
JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Then start tomcat using jpda:
catalina.sh jpda start
I checked my app at localhost, port 8000 and got an 'Unable to connect error'.
The next best solution was:
In catalina.bat file please modify the below.
Step 1: CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
Step 2: JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Step 3: Run Tomcat from command prompt like below: catalina.sh jpda start
When I checked localhost, port 8000 I got the same 'Unable to connect error'.
Attempting to connect to the tomcat debugger through Eclipse after both of these
attempts gave me an error:
Failed to connect to remote VM. Connection refused.
Connection refused
This made me think that port 8000 might be closed so I ran an nmap command to show
which ports on my 'localhost' were open. It returned the following:
ryan#ryan-K53E:~$ nmap -v localhost
Starting Nmap 5.21 ( http://nmap.org ) at 2013-04-15 22:12 BST
Initiating Ping Scan at 22:12
Scanning localhost (127.0.0.1) [2 ports]
Completed Ping Scan at 22:12, 0.00s elapsed (1 total hosts)
Initiating Connect Scan at 22:12
Scanning localhost (127.0.0.1) [1000 ports]
Discovered open port 80/tcp on 127.0.0.1
Discovered open port 3306/tcp on 127.0.0.1
Discovered open port 53/tcp on 127.0.0.1
Discovered open port 22/tcp on 127.0.0.1
Discovered open port 8080/tcp on 127.0.0.1
Discovered open port 631/tcp on 127.0.0.1
Completed Connect Scan at 22:12, 0.02s elapsed (1000 total ports)
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00028s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
80/tcp open http
631/tcp open ipp
3306/tcp open mysql
8080/tcp open http-proxy
Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds
This looks to confirm that port 8000 is closed so I defined 'tomcat-debug' as a service in the
'/etc/services' file like so:
tomcat-debug 8000/tcp # Remote tomcat debugging
Then tried to open port 8000 with iptables using the following command:
sudo iptables -A INPUT -p tcp --dport tomcat-debug -j ACCEPT
This doesn't seem to have made a difference as nmap is still showing the same list of open ports as
before. Any help here would be greatly appreciated.
Before checking if port 8000 is reachable form outside (your test with nmap) , have you tried to check if tomcat is listening on port 8000 ?
I'd use sudo netstat -pnl | grep 8000 to get a list of all process listening on port and filter this list for lines containing 8000.
you should receive something like this :
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 14236/java
This line tell that the process java (pid 14236) is listening for tcp on localhost(127.0.0.1) port 8000.
You should check that you tomcat process is listening on an external address if you want to connect to from external.

Cannot access an application hosted on jBoss remotely

I have hosted an application in a machine running Red Hat Enterprise Linux 5. I started the jBoss AS using the command.
./run.sh -b 0.0.0.0
and
./run.sh -Djboss.bind.address=<<server_address>>
and
./run.sh --host=<<ipaddress>>
but using any of these commands i cannot access the application remotely. Using the the above commands I cannot even access the application on the host machine itself, using localhost as well as ip address. I am not able to figure out the problem here. I can ping the linux machine from the other windows machines.
Check iptables rules are not blocking firstly
Also are you running as a user? If so, you will not have permission to bind to a port number less than 1024.
try telneting the port from the server itself to check the service is responding e.g.
telnet localhost 8080
presuming that you are running on 8080 in the example above.
you can drop your iptables temporarily for testing if it is safe to do so by:
/etc/init.d/iptables stop
and restart them when you've finished with
/etc/init.d/iptables start
you can make a permanent change to your iptables config by adding the following line to /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

Trying to connect to a remote server using Eclipse

I have an Ubuntu server running Tomcat, and I want to connect my Eclipse EE to it so I can work with JSP.
I have no problem connecting to a similar Tomcat service when it's installed on my machine (not a server), but whenever I try to connect to the remote server I don't seem to have the option of choosing a Tomcat service.
Is there some guide you can recommend (I didn't find one), or is there something I did wrong?
The "remote" Tomcat (or more generally the app server) must be configured to permit such connection.
Did you start the remote server with these parameters:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Alternatively you can add the word jpda at the end of the startup.sh (or .bat) script just when calling the catalina.sh script.
Everything is documented on the Apache Tomcat Wiki.
After enabling those options, you have also another task to do: enabling the network connection to the configured port (8000 in the above options). It depends which firewall is installed on the server but usually it is iptables.
Example of iptables command to enable connection to port 8000:
sudo iptables -A INPUT -p tcp --dport 8000 -j ACCEPT
If your server have a GUI installed, one easiest way is to use the "ufw" – short for 'uncomplicated firewall' as explained in this site which is just a graphical way to configure the iptables.
One way to test the connectivity to the server (if the port is open) is to use telnet from your computer like this:
telnet your.distant.host 8000
and if the command opens, the port is accessible, if the telnet command times out, the port is closed.