Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to set some linux services to non-standard ports - what's the highest valid port number?

share|improve this question
up vote 36 down vote accepted

(2^16)-1, or 0-65,535 (the -1 is because port 0 is reserved and unavailable). (edited because o_O Tync reminded me that we can't use port 0, and Steve Folly reminded me that you asked for the highest port, not the number of ports)

But you're probably going about this the wrong way. There are people who argue for and against non-standard ports. I say they're irrelevant except to the most casual scanner, and the most casual scanner can be kept at bay by using up-to-date software and proper firewall techniques, along with strong passwords. In other words, security best practices.

share|improve this answer
-1 for the wrong answer. Try 65,535. But good point about the argument for/against non-standard ports. – Steve Folly Jan 18 '10 at 0:00
There are security/compliance people who force these sorts of decisions. We run SMTP services on a predetermined high port to protect us against the security officer's office harassing us. – duffbeer703 Jan 18 '10 at 0:01
Steve, edited, and you're right. I answered the wrong question with my number :) – Matt Simmons Jan 18 '10 at 0:03
@Matt: removed -1 :-) – Steve Folly Jan 18 '10 at 0:05
If you're getting sick of those connection attempts and don't want to play directly with iptables, use fail2ban. – Anonymous Jan 18 '10 at 7:32

1-65535 are available, and ports in range 1-1023 are the privileged ones: an application needs to be run as root in order to listen to these ports.

share|improve this answer
No no. Ports 1-1023 are privileged ports. – Steve Folly Jan 18 '10 at 0:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.