How to change and start tomcat port in Linux server - linux

I tried to change the server.xml in the Tomcat7 from port=8080 to 8088.
When i start the server using ./startup.sh and then when i hit the URL http://:8088/
i get an error No Route to Host.
JBoss is already running on 8080 , so i want to run tomcat in a different port.

Related

Spring Boot App deployed on Azure App Service port 8080

I'm trying to deploy a Spring Boot Rest Api (Gradle) to an Azure app service. There is an executable jar in the /home/site/wwwroot folder and a startup command (java -jar /home/site/wwwroot/app.jar). When I execute this script, the spring api starts but throws the following error: "The Tomcat connector configured to listen on port 80 failed to start. The port may already be in use or the connector may be misconfigured."
I can't run the app on another port because the Azure App Service only allows inbound HTTP traffic on port 80 and 443 for SSL. I tried killing the process that is running on port 80 but that kills my ssh terminal.
Is there a solution to 'clear' the proces running on port 80 and actually run my Spring application on it?
"The Tomcat connector configured to listen on port 80 failed to start.The port may already be in use or the connector may be misconfigured."
The error is because another process is running on the same port. To solve this, you have two options.
Try to run the application on a port other than 8080.
Identify and stop the process running on that specific port.
Check this post on how to change the default tomcat port number.
See: how the spring boot configuration works.
Check this blog and SO thread might be helpful. Tomcat Server Error - Port 8080 already in use

App not starting with pm2 after stopping execution

I have an app set to listen to port 66.
First I tried to run it with sudo node myapp.js . I was able to access it at the correct url (ip:66). Then I stopped the app (Ctrl+c) and started it with pm2, sudo pm2 start app.js. The status is online. However, that same url is now inaccessible.
Running sudo pm2 logs while the app is started with pm2 gives me the error EACCESS for port 66. No one else is running the app, and I am sure I am only using one console and killing the node service before starting it with pm2.
Pm2 was installed globally. Server is Debian stretch. Nodejs version is 8.x
I am logging as a normal user and using sudo to run the app.
on linux systems normal users are not allowed to listen to ports below 1024. There are several ways around this.
You can change this rule to allow non root users to open such ports. But this is a security risc and is not recommended. So i won't add a link to this solution.
you can also listen to a port that is greater than 1024 and then use a forward rule in your firewall to route port 66 to the port you opened.
https://www.systutorials.com/816/port-forwarding-using-iptables/
my (and pm2's) prefered solution is to listen to a port greater than 1024 and use a reverse proxy like nginx to route apps running on that server.
http://pm2.keymetrics.io/docs/tutorials/pm2-nginx-production-setup

nodejs http-server, can't connect localhost

I am using nodejs http-server for a web application. I am able to launch the http-server by running nom start. I can access my server through http://127.0.0.1:8080 but I can't connect by http://localhost:8080. I have checked that localhost can be ping from my terminal and localhost works fine with other server such as tomcat. So I think the problem relates to http-server only. Is there any configuration I need to setup on my application in order to support localhost access?

Start Tomcat from Eclipse in port 80 ( Linux )

This question has been asked before, but no real answer has been given ( to the best of my knowledge).
Here is the link to the original question:
Start Tomcat from Eclipse in port 80 in Ubuntu with Authbind.
I do need torun tomcat on port 80.
I prefer not having to install tomcat on the computer. I believe it is not required.
I want to avoid using port forwarding ( I have to do it now since I find no other solution)
I am using:
Ubuntu 12.04
Eclipse Juno
Tomcat 7
OpenJDK 64-Bit Serve - java version "1.7.0_07"
I am able to start tomcat in port 80 as a non root user and without installing tomcat.
I follow this article:
http://java.dzone.com/articles/running-tomcat-port-80-user
There are a lot of articles about the topic, but I found this article to be simple an complete.
When I try to start tomcat using eclipse it always fails and complains about port 80 been used. But it is not true.In fact, while eclipse is running and while the error is been shown in the screen I am able to manually start tomcat on port 80.
I have noticed that eclipse complains about port 80 been used when it does not have access rights to that port. I did get the same error before I was not able to manually run tomcat on port 80. The difference is that when I manually run tomcat it did log an access right error, and eclipse complains about the usage of the port.
I have modified the eclipse tomcat launcher to include the option "-Djava.net.preferIPv4Stack=true" and to start tomcat as "authbind --deep start"
But I always get the same error.
If I start eclipse as root them it works fine, so I do believe the problem is related to the access rights on port 80 and not to port to been used.
I do assume that eclipse starts tomcat with the same user rights used to start eclipse.
Could anybody provide some support?. I can work by using port forwarding, but I would really like to know what I am missing and how to do it right.
The easiest way is to start tomcat with a listener on port 8080 and forward port 80 to localhost:8080:
ssh -L 80:localhost:8080 <user>#localhost
Execute this command with sudo
I thing to run something which uses the ports 1-1024 under Linux the process has to have the root privileges.
I am not sure if I can be helpful to anyone, but I solved similar problem as described: I started tomcat with startup.sh script, it was working fine on port 80. I restarted machine (just in case) and tried starting the same tomcat from eclipse, but when I got error about port 80 being used.
Turns out eclipse does not take startup scripts from tomcat installation, so it does not use the authbind configuration. The best solution I came up with is to start eclipse with authbind:
authbind --deep ./STS
As to why this didn't work:
I have modified the eclipse tomcat launcher to include the option "-Djava.net.preferIPv4Stack=true" and to start tomcat as "authbind --deep start"
As I understand you tried passing "authbind --deep start" as arguments to tomcat. I believe the point of authbind is to start application authbind with tomcat as argument. I don't see any way to do it in eclipse.
I am also now learning eclipse like u. Even i faced the same problem as you. Then, i changed the port number then server is starting now.
To change the port number, u need to double click the Apache Tomcat at servers. Then click on ports and change the HTTP/1.1 port to any four digit number u wish and save it.
It will work.

Start Tomcat from Eclipse in port 80 in Ubuntu with Authbind

I have installed Authbind to run Tomcat on port 80 in Ubuntu.
I have followed http://netthink.com/?p=362 to run Tomcat in Ubuntu in port 80.
When I run Tomcat on the command line by typing ./start.sh, Tomcat starts normally on port 80 without any exception.
In order to run Tomcat from Eclipse I installed the Tomcat plugin from http://www.eclipsetotale.com/tomcatPlugin.html. Everything is fine except that when I want to start Tomcat from Eclipse. When I run Tomcat from Eclipse by the Tomcat plugin, I get the following exception:
java.net.BindException: Permission denied :80
And if I add Tomcat as a server in "Server view" in Eclipse and want to start it from Server view I get this exception:
Port 80 required by Tomcat v6.0 Server at localhost is already in use
But I am sure that there is not any process that acquires port 80, because in the same time when I run Tomcat on the command line by typing ./start.sh, Tomcat starts normally on port 80.
How do I run Tomcat from Eclipse on port 80?
Using another port other than 80 and less than 1024 for Tomcat and start it in Server View in Eclipse gave me the same exception. For example, for port 82:
Port 82 required by Tomcat v6.0 Server at localhost is already in use
You said :
But i am sure that there is not any process that acquires port
80,because in the same time when i run Tomcat in command line by
typing ./start.sh ,tomcat starts normally in port 80.
Did you stop Tomcat in command line before starting it with Eclipse ?
To make sure your Tomcat is stopped, type this :
ps -ef|grep tomcat
You should have something like this if Tomcat is stopped :
user 16428 16373 0 13:56 pts/1 00:00:00 grep --color=auto tomcat
try running eclipse as root and then start tomcat (on port 80).. should work. although not an optimal solution. But should work since 80 is a privileged port in linux and requires sudo permissions to run.
You should start eclipse with: authbind --deep eclipse Since eclipse doesn't start tomcat via startup.sh file, inserting authbind there will have no effect.

Resources