DEV Community

Cover image for 5 Common Server Security Mistakes Developers Still Make

5 Common Server Security Mistakes Developers Still Make

5 Common Server Security Mistakes Developers Still Make

Even in 2025, server security is often treated as an afterthought.
Many developers assume cloud providers, hosting panels, or default configs are “secure enough”.

They’re not.

After managing production servers and hosting environments, I’ve seen the same security mistakes repeated again and again—even by experienced developers.

Let’s break down the 5 most common server security mistakes developers still make and how to fix them properly.

  1. Leaving Default Services and Ports Exposed

The Mistake

Fresh servers often come with:

  • Open SSH on port 22
  • Unused services running
  • No firewall rules

Attackers scan the internet 24/7 for these defaults.

The Fix

  • Disable unused services
  • Restrict SSH access
  • Use a firewall

Example (UFW):

ufw allow 2222/tcp
ufw enable
Enter fullscreen mode Exit fullscreen mode

Better:

  • Change SSH port
  • Allow SSH only from trusted IPs
  • Use key-based authentication

Security starts with reducing attack surface.

  1. Using Weak or Reused Passwords (Especially for Root)

The Mistake

  • Same password everywhere
  • Simple passwords for convenience
  • Root login enabled via password

This is how brute-force attacks succeed.

The Fix

  • Disable password-based root login
  • Use SSH keys
  • Enforce strong passwords

In /etc/ssh/sshd_config:

PermitRootLogin no
PasswordAuthentication no
Enter fullscreen mode Exit fullscreen mode

Then restart SSH:

systemctl restart sshd
Enter fullscreen mode Exit fullscreen mode

Convenience is not worth a compromised server.

  1. Assuming .htaccess Works Everywhere

The Mistake

Many developers rely on .htaccess for:

  • Blocking directories
  • Restricting access
  • Security rules

But .htaccess does NOT work on Nginx.

✅** The Fix**

If you’re using Nginx, security rules must go into Nginx config:

location /vendor/ {
    deny all;
    return 403;
}
Enter fullscreen mode Exit fullscreen mode

If your server uses Nginx + Apache, Nginx rules take priority.

Know your web server stack.

  1. Exposing Sensitive Files & Directories

The Mistake

Public access to:

  • /vendor
  • .env
  • configuration.php
  • Backup files
  • Git repositories

This is one of the fastest ways to leak credentials.

✅** The Fix**

  • Move application files outside public_html
  • Restrict access at the web server level
  • Set correct file permissions

Recommended permissions:

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
Enter fullscreen mode Exit fullscreen mode

If a file doesn’t need to be public, don’t make it public.

  1. Ignoring Updates & Security Patches

The Mistake

“I’ll update later.”

That’s how vulnerable servers stay vulnerable for years.

Most real-world hacks exploit:

  • Old PHP versions
  • Unpatched kernels
  • Outdated control panels

The Fix

  • Enable automatic security updates
  • Schedule maintenance windows
  • Monitor CVEs

On AlmaLinux:

dnf update -y
Enter fullscreen mode Exit fullscreen mode

Security patches are not optional—they’re part of production readiness.

Bonus Mistake: No Monitoring or Logs Review

Servers don’t get hacked silently.

Warnings are usually there:

  • Failed login attempts
  • Suspicious processes
  • Unexpected traffic spikes

If no one is watching, no one notices.

Fix:

  • Enable basic monitoring
  • Review logs periodically
  • Set alerts for abnormal behavior

Final Thoughts

Server security isn’t about being paranoid—it’s about being prepared.

Most breaches don’t happen because of zero-day exploits.
They happen because of basic mistakes that were never fixed.

If you:

  • Lock down access
  • Understand your server stack
  • Keep systems updated

You’re already ahead of most deployments.

Top comments (0)