🀝 Play together

The one-time fix for β€œwhen I join while somebody else is in the game, one of us gets thrown out”.

Why it happens. Civ4 connects every player directly to every other player, even on a Pitboss server. Two people behind home routers can't open that connection on their own, so the game asks GameSpy's β€œNAT negotiation” servers to broker it β€” and those have been dead since 2014. The game waits, gives up, and drops one of you. Joining alone always works because the server itself has a public address.

The fix. Tell your PC that the GameSpy hostnames now live at civpb.com. Our server answers in GameSpy's place and relays the connection between the two of you, so it works even on mobile or CGNAT internet, with no port forwarding. That's the whole change: fifteen lines in your hosts file. Nothing in the game is touched.

  1. Press Start, type cmd, right-click Command Prompt β†’ Run as administrator. (PowerShell as administrator works just as well.)
  2. Copy this line, paste it into the window (right-click pastes), press Enter:
    powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (iwr -UseBasicParsing https://civpb.com/files/natneg.ps1).Content"
  3. Restart Civ4 if it was running. Done β€” for good, on this PC.

It runs natneg.ps1 straight from civpb.com (20 lines, open the link to read it): backs up your hosts file next to itself; drops any older natneg lines (Windows uses the first match, so a lobby hosts file would otherwise win); appends the lines below; flushes the DNS cache. Nothing else. No file lands on your disk, so there is nothing for the antivirus to complain about.

Check it worked: in the same window type ping natneg1.gamespy.com β€” it should answer from 46.224.21.154.

Or: replace the hosts file by hand β€” no command line
  1. Download the ready-made file: ⬇ hosts β€” or, if you play in Kvalitet's lobby too: ⬇ hosts (with Kvalitet lobby)
    Both are plain text. The first is Windows' default hosts file plus our lines; the second also carries Kvalitet's lobby entries with the natneg ones pointing here.
  2. Open the folder C:\Windows\System32\drivers\etc in Explorer (paste the path into the address bar).
  3. Rename the existing hosts to hosts.old (Windows asks for administrator permission β€” click Continue).
  4. Copy the downloaded file in; its name must be exactly hosts, no extension. If your browser saved it as hosts.txt, rename it (enable β€œFile name extensions” in Explorer's View menu to see it).
  5. Open Command Prompt and run ipconfig /flushdns, or just reboot.

Careful if you had your own entries in hosts (blocked sites, local servers): this replaces the whole file β€” use the paste-into-Notepad way instead: Start β†’ type notepad β†’ right-click β†’ Run as administrator β†’ File β†’ Open β†’ C:\Windows\System32\drivers\etc\hosts (file filter β€œAll files”), delete any line containing natneg, paste the lines below at the end, save, then ipconfig /flushdns.

There is also a civpb-natneg.bat that does the same as the command; browsers and Defender flag every downloaded .bat as dangerous on principle.

Civ4 under CrossOver or Wine uses the Mac's own hosts file. Open Terminal and paste this one line (it asks for your Mac password, which is not shown while typing):

curl -fsSL https://civpb.com/files/hosts-natneg.txt | sudo tee -a /etc/hosts >/dev/null && sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder && echo done

If you already have natneg lines from a lobby hosts file, remove them first β€” macOS also uses the first match: sudo nano /etc/hosts.

Parallels / Boot Camp: that is a real Windows β€” use the Windows tab inside it.

Check it worked: ping -c1 natneg1.gamespy.com β†’ 46.224.21.154.

curl -fsSL https://civpb.com/files/hosts-natneg.txt | sudo tee -a /etc/hosts >/dev/null && echo done

Wine and Proton read the system /etc/hosts. Remove older natneg lines first if you have them.

πŸ“„ The lines

46.224.21.154 natneg1.gamespy.com
46.224.21.154 natneg2.gamespy.com
46.224.21.154 natneg3.gamespy.com
46.224.21.154 civ4bts.natneg1.gamespy.com
46.224.21.154 civ4bts.natneg2.gamespy.com
46.224.21.154 civ4bts.natneg3.gamespy.com
46.224.21.154 civ4.natneg1.gamespy.com
46.224.21.154 civ4.natneg2.gamespy.com
46.224.21.154 civ4.natneg3.gamespy.com
46.224.21.154 natneg1.g.zulan.net
46.224.21.154 natneg2.g.zulan.net
46.224.21.154 natneg3.g.zulan.net
46.224.21.154 civ4bts.natneg1.g.zulan.net
46.224.21.154 civ4bts.natneg2.g.zulan.net
46.224.21.154 civ4bts.natneg3.g.zulan.net

Why two families of names: the original game asks gamespy.com; the patched launcher most of us use (BTS_Wrapper / Civ4BeyondSword2015.exe) was built with Zulan's names inside it and asks g.zulan.net β€” his box still answers, but without a relay. Both now point here. Undo: delete these lines from your hosts file. hosts-natneg.txt

πŸ” Details, for the curious

What we run
A GameSpy NAT-negotiation server (same protocol the community servers have used since 2014, source on GitHub: PRMasterServer) with one twist: instead of telling two clients each other's address and hoping the hole-punch works, it gives both a port on civpb.com and forwards the packets. UDP 27901 for the handshake, 27910–27999 for relays.
What goes through it
Only the traffic between two clients who are in the game at the same moment β€” a few kB/s. Your connection to the Pitboss server itself is direct, as before.
Privacy
The server logs the negotiation (your public IP, like any server you connect to) and byte counts. Game packets are forwarded, not stored.
Kvalitet's lobby
Unaffected. His hosts file and ours differ only in the natneg lines; with ours installed, his lobby games are brokered through civpb.com too, which is fine.