36

When I open my file list-student.jsp. I experienced the following error:

Starting Tomcat v9.0 Server at localhost has encountered a problem. The server cannot be started because one or more of the ports are invalid. Open the server editor and correct invalid ports.

I tried to go server tab and change the port from 8080 to different number, but it doesn't work. I had the same problem before and I changed 8080 to another number liked 8181 and it worked, but today, even I tried to change port number and the problem can't be fixed.

Changing port number

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
BouncySmoke
  • 403
  • 1
  • 4
  • 6
  • 'Invalid' isn't the same thing as 'in use'. Something wrong with your web.xml. Off topic. – user207421 Jan 01 '20 at 02:15
  • Hi there, i don't know what problems happened, so decided to deleted the server and set up a new one. Everything works fine now. Thanks for your comment – BouncySmoke Jan 02 '20 at 03:14

17 Answers17

95

The issue is that the Tomcat admin port was not defined. You need to have it as an actual number such as 9000 rather than as a hyphen -.

Tomcat 9 configuration page (Eclipse)

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Joseph Waweru
  • 1,680
  • 18
  • 14
  • 20
    experienced the same. who's decision think this is a great idea to make the default port a hyphen. "yeah, lets make millions of developer pain right starting tomcat" – Mr. Brickowski Jan 08 '20 at 01:54
  • 1
    Why to define an admin port? Moreover, in the server.xml it doesn't even is called that way. When the change put forward is done a " – Pedro García Medina Apr 02 '20 at 04:46
23

This issue came in Tomcat 9 version starting from Eclipse.

The server cannot started because one or more of the ports are invalid

Only Modify the server ports "Tomcat Admin Port" default value from hyphen (-) to zero(0) it's working fine.

enter image description here

Saket Yadav
  • 967
  • 1
  • 10
  • 23
14

This is because the tomcat admin port or any other port was not defined.

enter image description here

Click ok and open the tomcat server at localhost.

enter image description here

In the highlighted area, if the port number is not defined then give it a port number, save the file and run again.

Arya
  • 547
  • 5
  • 5
12

This is how i fixed this : Go to Eclipse => Window => Show View => Servers => DoubleClick on Tomcat Server => Change admin port to "1" and leave the HTTP port to "8080" . Make sure to kill any processes which are running on port 8080.You will find your project on localhost:8080/java project name , if you don't add java project name it will give you error 404. Hope this works !

Arbis Malasi
  • 121
  • 1
  • 6
3

What is did is : Eclipse->Window ->Show View->Servers->DoubleClick on Tomcat Server-> Change admin port to "1" and leave the HTTP port to "8081" . Make sure to kill any processes which are running on port 8080. You will find your project on localhost:8081/java project name, worked for me!

Barshi
  • 191
  • 2
  • 6
2

go to this location C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\conf

and copy server.xml file and paste on desktop

open server.xml from desktop just change -1 to 1 at following tag

<Server port="1" shutdown="SHUTDOWN">
kk.
  • 3,747
  • 12
  • 36
  • 67
Anil Amane
  • 555
  • 7
  • 12
2

Add available port number in Tomcat admin port fixed the issue.

User
  • 1,460
  • 14
  • 11
2

Just to add my two cents. I installed Apache Tomcat 10.0 and had the same issue in Eclipse. I change the - for the Admin port and everything worked fine afterwards.

Steve K
  • 21
  • 1
1

In Eclipse, navigate to Window -> Show View -> Servers. A new tab pane entitled 'Servers' should appear (at the bottom) on the screen. Double click on your instance of Tomcat and a pane entitled 'Overview' should open (above). On the right side of this should be a pane entitled 'Ports'. I set the Tomcat admin port = 1. Now, right click on your Tomcat instance in the 'Servers' tab pane and select the start option. If this works the status of the Tomcat instance will change from stopped to running. In my case I was warned that port 8080 was in use (by an instance of Tomcat running outside of Eclipse). You have two options here. Run the Windows Services manager dialog and stop the Tomcat instance using port 8080, or go back to the 'Ports' pane in Eclipse and set the port to 8081. I went for the latter option, and was able to start Tomcat within Eclipse.

Clarius
  • 1,183
  • 10
  • 10
1

If using Spring-Tools v4 IDE you can open Tomcat setting:

Window -> Show View -> Server

or

Window -> Show View -> Other -> Server -> Servers (double-click)

Bottom menu must show "Servers" menu...

enter image description here

Double click on "Tomcat v8xx" in the menu...

Edit the "Tomcat admin port" replace the - character with 1

enter image description here

Close and Save the changes and restart IDE. Tomcat must be started by the app calling it not manually

0
  • Open cmd and type netstat -a
  • Find port 8080 is running or not
  • Open "windows defender firewall with advanced security" and select Inbound Rules next new Rule next select "Port" next Specific local ports: 8080 next select Block the connection next type a name and finish, now restart your system.
  • Open Services.msc find Apache Tomcat V.x and stop it.

That's it

Hamed Karami
  • 405
  • 1
  • 6
  • 28
0

declare all undeclared ports in the server window, and save.

0

In the server folder find the server.xml file and change the following to

<Server port="1" shutdown="SHUTDOWN">

and

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

to

<Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443"/>
Gamal Mohamed
  • 111
  • 1
  • 3
0

Double click the Tomcat server and in overview window set available ports numbers to Tomcat admin port and HTTP/1.1

User
  • 1,460
  • 14
  • 11
0

I really thank the person who came with idea of reconfiguring the admoinistration port as follows PortNmae Port number Tomcat 9000 HTTP/1.1 9090 AJP/1.3 9000 This configuration worked smoothly for me

0

I gave a lot of time on this one.

enter image description here

Double Click on highlighted area(Tomcatv9.0)-->change Tomcat admin port to 1 && HTTP/1.1 to 8081

this should work :)

-1

I have been solving this issue with trial n error and come with the solution

Right click on server tap on open/F3 change your port to anything but not - (hyphen). If it still showing error try another one by adding one no. To the port no. And its done