Question

Why can my application not use port 8080?

I am trying to run an application, but it doesn’t start, returning the following error: The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

I tried using netstat to see what application is using port 8080, but it does not seem that there is any application listening on that port.

I tried changing the port to 8081 and 8082, but was unable to connect with those either.

Finally I used sudo to run the application and now it does start, however I do not want to run the application with root access.

Why can my application not use port 8080 without root access?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

I have found the solution, it didn’t actually have anything to do with the port, the error message sent me looking in the wrong direction. My application didn’t have access to the keystore file where the ssl key was stored, so I needed to change the permissions on that file. After that my app worked fine.

This answer gave me the right clue, 6th answer on a relevant stackoverflow post. :') https://stackoverflow.com/a/56584497/10088785

KFSys
Site Moderator
Site Moderator badge
September 1, 2021

hi @simonprins,

You need root to start a service. It’s how it works.

If you do wish to start the systemd service without root though, you can use the sudoers file. In the sudoers files you can do something like :

Note: for the example the user and group is called DOquestion Put code in a custom file here: /etc/sudoers.d/DOquestion Code:

%DOquestionALL= NOPASSWD: /bin/systemctl start my_app
%DOquestionALL= NOPASSWD: /bin/systemctl stop my_app
%DOquestionALL= NOPASSWD: /bin/systemctl restart my_app

The above should do the trick.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.