Site AI AuditInternet Solutions द्वारा

Open Ports on Your Web Server: Which Ones to Close

13 अक्तूबर 20268 मिनट पढ़ेंसुरक्षा और SSL
Open Ports on Your Web Server: Which Ones to Close

Short answer: A typical website needs only two ports open to the whole internet: 80 for HTTP, which should redirect, and 443 for HTTPS. Mail servers add their mail ports. Administrative services such as SSH, control panels and remote desktop should be limited to known IP addresses or a VPN, and databases, caches and internal APIs should never be reachable from the internet. Check from outside with a port scanner, compare the result with what you expect, and close the rest with a firewall.

What an open port is

A server can run many network services at the same time: a web server, a database, an SSH server for administration, a mail server, a cache. Each service listens on a port number. If the firewall allows connections to that port from the internet, the port is “open”, and anyone in the world can try to talk to the service behind it.

Automated scanners do exactly that, all day, across the whole internet. Search engines for internet-connected devices index open services and their versions, so an exposed database or admin interface can be found within hours of going online. Every open port is a service that must be patched, configured and protected. Fewer open ports means fewer things that can go wrong.

Ports a website actually needs

PortServiceWho should reach it
443HTTPSEveryone
80HTTP, redirecting to HTTPS and used for some certificate checksEveryone
22SSH or SFTP administrationYour team’s IP addresses or VPN only
25SMTP between mail serversEveryone, only if this server receives mail
587, 465Mail submission from email clientsYour users, only if this server hosts mailboxes
993, 995IMAP and POP3 over TLSYour users, only if this server hosts mailboxes
2083, 2087, 8443 and similarHosting control panelsYour team only, where possible
3306, 5432MySQL, PostgreSQLNobody from outside; local or private network only
6379, 11211Redis, MemcachedNobody from outside

Port 80 is worth keeping open even on an HTTPS-only site, so that visitors typing the address without https are redirected. Our guide to the HTTP to HTTPS redirect explains how to set that up correctly. For mail ports, see SMTP ports 25, 587 and 465.

The most dangerous exposed services

How to check your server from outside

What matters is what the internet sees, not what you think is configured. Check from a network outside your server:

  1. Run a port scan of your own server’s public IP address. The open-source tool Nmap is the standard: nmap -Pn your.server.ip checks common ports, and nmap -Pn -p- your.server.ip checks all 65,535 TCP ports. Only scan servers you own or have permission to test.
  2. List what listens locally. On Linux, ss -tulpn shows every service and the address it listens on. A service bound to 127.0.0.1 is only reachable from the server itself; one bound to 0.0.0.0 or :: listens on all interfaces and relies on the firewall.
  3. Compare the two lists. Every port that is open from outside should be on your “needed” list. Anything else is a finding.
  4. Check IPv6 too. Firewall rules are sometimes written only for IPv4, leaving the same services open on the server’s IPv6 address.

If you are on shared hosting, the provider manages the firewall and you usually cannot change it. Port questions then become questions for your host, while you focus on the parts you control, such as the application and its file permissions.

How to close or restrict ports

There are three levels, and the strongest setups use all of them:

Remove services you do not use at all. A service that is not installed cannot be attacked.

Traps that leave ports open by accident

Make it a regular check

Ports change whenever someone installs software, changes hosting or deploys a new container. A light routine catches problems early:

Open ports on shared hosting, VPS and cloud servers

Who is responsible for ports depends on the kind of hosting you use:

Whatever the setup, write down who owns the firewall. Many exposed databases are not the result of an attack, but of each party assuming the other had closed the port.

How Site AI Audit helps

Site AI Audit checks your website through the web, the way visitors and search engines see it, and does not scan other ports. It checks the parts of the web service that face everyone: whether the site works over HTTPS, whether HTTP redirects to HTTPS, whether the SSL certificate is valid, trusted, matches the domain and when it expires, whether HSTS and other basic security headers are set, and whether the server or WordPress reveals its version. Use it next to a port scan of your own server. You can run a free check; plans with monitoring are on the pricing page.

Related reading

The bottom line

Expose only what your website and mail need: 443 and 80 for everyone, mail ports only where mail is hosted, admin services only for your team, and databases and caches for nobody outside. Bind internal services to local addresses, use a default-deny firewall, watch out for Docker and temporary rules, and scan your server from outside regularly.

FAQ

Which ports should be open on a web server?

Usually only 443 for HTTPS and 80 for the redirect to HTTPS. Add mail ports if the server handles email, and allow SSH or control panels only from trusted addresses.

Is it dangerous to have port 22 open?

An SSH port open to everyone attracts constant password guessing. It is much safer to allow it only from known IP addresses or a VPN, use key-based login and disable password login.

How do I check which ports are open on my server?

Scan the server’s public IP address from another network with a tool such as Nmap, and list listening services on the server with ss -tulpn. Compare both with the ports you expect.

Should MySQL port 3306 be open to the internet?

No. Databases should listen only on the local or private network. If a remote application needs access, use a private network, a VPN or an SSH tunnel instead.

Why is a Docker port open when my firewall blocks it?

On Linux, Docker inserts its own firewall rules for published ports, which can bypass host firewall tools such as ufw. Publish internal ports on 127.0.0.1 only, or not at all.

#Checklists#Web hosting#Website security
अपनी वेबसाइट जाँचें — मुफ़्त।आपकी वेबसाइट में क्या ठीक करना है — और शुरुआत कहाँ से करें।
मुफ़्त शुरू करें

ब्लॉग से और

सभी लेख →
Internet Solutions

हमारी टीम के और प्रोडक्ट

Internet Solutions द्वारा बनाए गए। हमारे बाकी प्रोडक्ट भी आज़माएँ — हर एक अलग तरीके से आपका समय बचाता है।

internet-solutions.net ↗
01सोशल मीडिया ऑटो-पोस्टिंग
PostRSS

आपकी RSS फ़ीड की नई पोस्ट अपने-आप Facebook, X, LinkedIn, Telegram और 60+ अन्य नेटवर्क पर पहुँच जाती हैं।

मुफ़्त प्लान · 2014 सेदेखें →
02वेबसाइटों के लिए AI लाइव चैट
Talkmio

आपकी वेबसाइट आपके अपने कंटेंट से, विज़िटर की भाषा में, 24/7 जवाब देती है।

मुफ़्त प्लान · कार्ड की ज़रूरत नहींदेखें →
03AI असिस्टेंट
Ask Mio

चैट, कोड, डिज़ाइन, लेखन और रिसर्च। Mio हर काम के लिए सबसे अच्छा मॉडल चुनता है।

मुफ़्त प्लानदेखें →
04ब्लॉग और सोशल मीडिया के लिए AI ऑटोपायलट
AI Blog Autopilot

AI 2,000–3,000 शब्दों के SEO लेख लिखता है और हर लेख को 60 सोशल नेटवर्क पर शेयर करता है।

पहले 3 लेख मुफ़्तदेखें →
05गहन SEO क्रॉल
Site SEO AI Audit

7 क्षेत्रों में पूरा SEO क्रॉल, AI सर्च में दृश्यता सहित, असर के हिसाब से क्रमबद्ध सुधारों के साथ।

पहला ऑडिट मुफ़्तदेखें →
06RSS और प्रोडक्ट फ़ीड
RSS Feed Creator

किसी भी वेब पेज से RSS बनाएँ, साथ ही Google और Meta के लिए अपने-आप अपडेट होने वाली प्रोडक्ट फ़ीड।

मुफ़्त प्लानदेखें →
07वेब डेवलपमेंट और SEO
Internet Solutions

वेबसाइटें, ई-शॉप और कस्टम सिस्टम — हमारी टीम डिज़ाइन करती है, बनाती है और चलाती है।

2011 सेदेखें →