title: Error in parallel processing: port cannot be open
body: <p>I am running different R scripts in batch mode at once in a linux cluster to estimate a model in different data sets (it also happens when I run it in Mac). The scripts are exactly the same, except for the data set that they are using. I get the following message when I do that.</p>
  
  <pre><code>Error in socketConnection("localhost", port = port, server = TRUE, blocking = TRUE, : 
  cannot open the connection
  Calls: makePSOCKcluster -&gt; newPSOCKnode -&gt; socketConnection
  In addition: Warning message:
  In socketConnection("localhost", port = port, server = TRUE, blocking = TRUE, :
  port 11426 cannot be opened
  </code></pre>
  
  <p>Here is a reproducible example. Create two files, tmp1.R and tmp2.R, and tmp.sh with the content:</p>
  
  <p>Content of the files tmp1.R and tmp2.R:</p>
  
  <pre><code>library(dclone)
  l &lt;- list(1:100,1:100,1:100,1:100)
  cl &lt;- makePSOCKcluster(4)
  parLapply(cl, X=l, fun=function(x) {Sys.sleep(2); sum(x); })
  stopCluster(cl)
  </code></pre>
  
  <p>Content of the tmp.sh file:</p>
  
  <pre><code>#!/bin/sh
  R CMD BATCH tmp1.R &amp;
  R CMD BATCH tmp2.R &amp;
  </code></pre>
  
  <p>The first file in the list will be executed. The second will present the error above. Does anyone know how to solve it and still run all the scripts at once automatically without any manual intervention?</p>
  
  <p>PS: I have read all the other similar questions, none have a reproducible example or an answer to the question above.</p>