Fix ERROR_INVALID_PORT_ATTRIBUTES (0X00000221)
This error means Windows can't open a network port because of wrong settings. Usually it's a firewall or antivirus blocking the port. Here's how to fix it.
What causes error 0X00000221?
You'll see this error when an application tries to open a network port but Windows says the port attributes are invalid. The number is 0X00000221 (decimal 545). It usually pops up in server apps, database connections, or file-sharing tools. Real-world trigger: you're setting up an FTP server on Windows 10 or 11 and it fails to bind to port 21. Or you're running a game server and the port binding fails.
The port attributes are settings like IP address, protocol (TCP/UDP), and permissions. When Windows can't match what the app requests with what's actually configured, you get this error. The fix is almost always about clearing a conflict — not a hardware problem.
Fix 1: Windows Firewall is blocking the port
This is the most common cause. The Windows Firewall sees the port request and goes "nope, that's not allowed." Even if you think you've allowed the app, sometimes the rule is for the wrong protocol or the wrong IP range.
Here's how to check and fix it:
- Press Windows Key + R, type
wf.msc, and hit Enter. This opens Windows Defender Firewall with Advanced Security. - In the left pane, click Inbound Rules. You'll see a long list of rules.
- Look for a rule that matches your app or port. If you're using port 8080 for a web server, look for that. If there's no rule, you need to create one.
- Click New Rule... in the right pane. The New Inbound Rule Wizard opens.
- Select Port and click Next.
- Select TCP or UDP (match your app). Choose Specific local ports and type the port number your app uses. Click Next.
- Select Allow the connection. Click Next.
- Leave all three checkboxes (Domain, Private, Public) checked. Click Next.
- Give it a name like "My App Port 8080" and click Finish.
- After you click Finish, the rule appears in the list. It should have a green checkmark showing it's enabled. Expected outcome: Your app should now be able to bind to that port without error 0X00000221. Test it by restarting your app.
If you already have a rule, double-click it. Go to the Scope tab. Check that the local IP addresses include the one your app is using. If it says "Any IP address," that's fine. If it's set to a specific IP that doesn't match, change it. Also check the Protocols and Ports tab — make sure the protocol (TCP/UDP) matches.
Fix 2: Third-party antivirus or security software is interfering
This is the second most common cause. Also the most annoying because antivirus software doesn't always show a popup when it blocks a port. It just silently says "nah, that's risky" and Windows throws the invalid port attributes error.
I've seen Norton, McAfee, Bitdefender, and Kaspersky all do this. Even the built-in Windows Defender Antivirus can interfere if real-time protection is too aggressive.
Here's the fix:
- Open your antivirus software. Look for a section called Firewall, Network Protection, or Application Control.
- Find the app that's getting the error (your FTP server, game server, etc.). Add it to the allowed list or exceptions list. Sometimes it's called "allow through firewall" or "application rule."
- If you can't find the app easily, temporarily disable the antivirus's firewall module. But don't turn off the whole antivirus — just the network protection part.
- After making the change, restart your app. Expected outcome: The error should disappear. If it does, you know the antivirus was the problem.
- If disabling the firewall module fixes it, add a permanent exception for your app. Never leave the firewall disabled.
One real-world case: I helped a user who ran a Plex media server. Error 0X00000221 appeared every time they tried to add a remote access port. Turned out Bitdefender's "network threat prevention" was blocking port 32400. Adding Plex to the allowed apps list fixed it immediately.
Fix 3: Corrupted network stack — reset Winsock and TCP/IP
If you've checked the firewall and antivirus and the error still shows up, Windows itself might have a corrupted network stack. This happens after a bad update, a failed uninstall of a VPN client, or some malware removal tool that messed up the settings.
Here's how to reset it:
- Right-click the Start button and select Windows Terminal (Admin) or Command Prompt (Admin). You need admin rights for this.
- Run these commands one at a time. Press Enter after each one. Wait for each to finish before running the next.
netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
ipconfig /flushdns
After running these, restart your computer. Expected outcome: After the restart, your network settings are back to factory defaults. Your port binding should work now. If the error is gone, great. If not, move to the next fix.
Fix 4: The port is already in use by another service
Less common, but happens when two apps try to grab the same port. Windows gives the invalid port attributes error because it can't assign the port to a second app. The first app got it.
To check which app is using your port:
- Open Command Prompt as admin.
- Type
netstat -ano | findstr :8080(replace 8080 with your port number). - Look at the output. The last column is the PID (process ID). Example:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 12345. Here 12345 is the PID. - Open Task Manager (Ctrl+Shift+Esc). Go to the Details tab. Find the process with that PID. If you don't see a PID column, right-click any column header and select PID.
- If it's a service you don't need, right-click it and select End task. Or just change your app's port to a different number.
Expected outcome: After killing the conflicting process, your app should bind to the port without error. If you keep the same port, restart your app.
Quick-reference summary table
| Cause | What to do | How long it takes |
|---|---|---|
| Windows Firewall blocking the port | Add an inbound rule allowing the port | 10 minutes |
| Third-party antivirus interfering | Add app to allowed list in antivirus | 15 minutes |
| Corrupted network stack | Run netsh and ipconfig commands, restart | 20 minutes |
| Port already in use | Find and stop the conflicting process | 5 minutes |
Start with Fix 1 — that's where the problem lives nine times out of ten. If you're still stuck after trying all four, you might be dealing with a corrupted Windows installation. In that case, run sfc /scannow and DISM /Online /Cleanup-Image /RestoreHealth from an admin command prompt. Those will repair system files that could be causing the port attribute issue.
Was this solution helpful?