0

I tried setting the following in my /etc/sysctl.conf file to try and help with a MySQL port exhaustion issue:

net.ipv4.tcp_tw_reuse = true
net.ipv4.tcp_tw_recycle = true

But I get an error when running sysctl -p:

sysctl: setting key "net.ipv4.tcp_tw_reuse": Invalid argument
sysctl: setting key "net.ipv4.tcp_tw_recycle": Invalid argument

I also tried setting it this way, with no arguments:

net.ipv4.tcp_tw_reuse
net.ipv4.tcp_tw_recycle

And I get this response back on executing sysctl -p:

sysctl: /etc/sysctl.conf(31): invalid syntax, continuing...
sysctl: /etc/sysctl.conf(32): invalid syntax, continuing...

Can someone please tell me how to set these values correctly?

Thanks

bluethundr
  • 1,005
  • 17
  • 68
  • 141

2 Answers2

6

So that syntax is for the linux kernel, and you would use 1 or 0 for true/false, not the actual spelled out words. So in your example, it would be:

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

If you're trying to adjust this setting in OSX on your Mac, then it's a different syntax. It would be:

net.inet.tcp.msl=1000

Hope that helps.

CRMcMullen
  • 76
  • 1
  • 3
  • sudo sysctl net.inet.tcp.msl=1000 and net.inet.tcp.msl = Maximum segment lifetime – zhuguowei Mar 07 '20 at 07:06
  • according to https://djangocas.dev/blog/troubleshooting-tcp_tw_recycle-no-such-file-or-directory/?fbclid=IwAR1OkN5VsZPXH_AjsEZZbRLkV5ImhhxALVZf3H6c4VtDhgC36KucpVUMFkA net.ipv4.tcp_tw_reuse is removed – zolty13 Mar 14 '23 at 09:15
0

If it's still actual for you - "true" is wrong value here, you have to use 1 as "enabled" and 0 as "disabled"

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/10673634) – Alex Dec 24 '15 at 09:07
  • I think it does answer the question. I don't know if its the right answer, but it is ans answer. – Rohit Gupta Dec 24 '15 at 09:42
  • @alirezasafian Hm. I don't think so. Author wants to set variables and obtains syntax errors. He doesn't ask which variables he should set. He just want to "set these values correctly". Correctly way is use 1 instead true – Evgenii Kazmiruk Dec 24 '15 at 10:53