How do I configure a port in my .conf file? This is what my conf file looks like:
prune=600
maxconnections=12
maxuploadtarget=20
rpcuser=user
rpcpassword=password
keypool=10000
server=1

[main]
rpcport=5040

Whenever I run this from the command line I get the following error:

Binding RPC on address ::1 port 5040 failed.
Binding RPC on address 127.0.0.1 port 5040 failed.

I checked for port 5040 using the netstat -a and it was listening, what's the problem?
Windows 10


Run netstat -ab &gt;file.txt then notepad file.txt and search on 5040. I suspect you will find CDPSvc immediately underneath - on my machine this "Connected Devices Platform Service" is already using your port. 

If that's so, search on 5041, then 5042 and continue up until search can't find it. That port is free: change your rpcport to match it.