Error when running exp publish: socket hang up

Whenever i try to run exp publish on CircleCI (either Ubuntu 12.04 or 14.04, w/ node 7.10.0), i run into the following error:

[exp] Making sure project is set up correctly...
[exp] Your project looks good!
[exp] Unable to find an existing exp instance for this directory, starting a new one...
[exp] Starting React Native packager...
[exp] Scanning 847 folders for symlinks in /home/circleci/repo/node_modules (23ms)
[exp] Loading dependency graph.
[exp] Running packager on port 19001.
[exp] Publishing...
[exp] Building iOS bundle
[exp] socket hang up
Building JavaScript bundle [] 0%Error: socket hang up
    at createHangUpError (_http_client.js:302:15)
    at Socket.socketOnEnd (_http_client.js:394:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:188:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
Exited with code 1

Any ideas? Thanks much!

Could you try setting adding a key in your app.json (under the expo) key called packagerOpts, and then setting that to:

  nonPersistent: true

This will disable watch mode in the packager, which may help here.

Let me know!

Thanks for the tip, @skevy!

After adding that flag to the packagerOpts section, the packager seems to not recognize that option and hang:

circleci@ed1625d76dec:~/repo$ exp publish
[exp] Making sure project is set up correctly...
[exp] Your project looks good!
[exp] Unable to find an existing exp instance for this directory, starting a new one...
[exp] Starting React Native packager...
[exp] Scanning 847 folders for symlinks in /home/circleci/repo/node_modules (11ms)
[exp] Usage: cli [options] mand]
[exp]   Options:
[exp]     -V, --version  output the version number
[exp]     -h, --help     output usage information
[exp]   Commands:
[exp]     start [options]                    starts the webserver
[exp]     run-ios [options]                  builds your app and starts it on iOS simulator
[exp]     run-android [options]              builds your app and starts it on a connected Android emulator or device
[exp]     new-library [options]              generates a native library bridge
[exp]     bundle [options]                   builds the javascript bundle for offline use
[exp]     unbundle [options]                 builds javascript as "unbundle" for offline use
[exp]     eject [options]                    Re-create the iOS and Android folders and native code
[exp]     link [options] [packageName]       links all native dependencies (updates native build files)
[exp]     unlink [options] <packageName>     unlink native dependency
[exp]     install [options] <packageName>    install and link native dependencies
[exp]     uninstall [options] <packageName>  uninstall and unlink native dependencies
[exp]     upgrade [options]                  upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
[exp]     log-android [options]              starts adb logcat
[exp]     log-ios [options]                  starts iOS device syslog tail
Stopping packager...
Packager stopped.

Here’s my app.json for reference:

  "expo": {
    "name": "Fuzzy Pet Health",
    "sdkVersion": "19.0.0",
    "icon": "./App/Images/app-icon.png",
    "version": "2.0.0",
    "slug": "fuzzy-mobile",
    "ios": {
      "bundleIdentifier": "com.yourfuzzy.fuzzyhealth"
    "android": {
      "package": "com.yourfuzzy.fuzzy"
    "packagerOpts": {
      "nonPersistent": true

Thanks again for your help! I really appreciate it.

:confused: I’m sorry it didn’t work.

I just made a change in XDL (the library that underpins exp) to allow for this packager option to be set. That change will go it in the next release.

Ahh, thanks for pointing me towards XDL!

After digging into how it generates arguments for react-native-cli from the value of packagerOpts and in what format react-native-cli expects arguments to be in, I think I came to the same realization you did:

Interestingly, since the CLI allows duplicate boolean arguments, I can very ugly-ly hack my way around this until your commit is shipped by using the following monstrosity:

"packagerOpts": {
      "nonPersistent": "--nonPersistent"

Thank you so much for the quick fix!

1 Like

Hey guys, I have the same issue and adding this to my app.json allows it to build…

… but it stops the packager from picking up changes on the file system when developing, which is painful to say the least!

Any ideas how to get around this? I can probably have my CI process inject the options into the file but it seems a bit hacky…


Try running yarn start / npm run start at your project. When I had this issue it was related the warning below because I’ve restarted my pc.

See for more information, either install watchman or run the following snippet:
sudo sysctl -w fs.inotify.max_user_instances=1024
sudo sysctl -w fs.inotify.max_user_watches=12288
error Command failed with exit code 1.
info Visit yarn run | Yarn for documentation about this command.

When I run the commands it solved the exp start / exp build:android proccess

I tried to use:

"packagerOpts": {
      "nonPersistent": "--nonPersistent"

but the socket hang up error persists. Some other solution?

I’ve had the same problem once I upgraded to Expo SDK 31. Builds in Travis were fine with SDK 30, but now it’s suddenly busting on 31.

I’ve tried using

"packagerOpts": {
  "nonPersistent": true


"packagerOpts": {
  "nonPersistent": "--nonPersistent"

but both still result in the same error:

Building iOS bundle
    throw error;

Error: watch /home/travis/build/transparentclassroom/TransparentClassroom/node_modules/escodegen/node_modules/source-map/lib ENOSPC
    at FSWatcher.start (fs.js:1382:19)
    at (fs.js:1408:11)
    at NodeWatcher.watchdir (/home/travis/build/transparentclassroom/TransparentClassroom/frontend/native/node_modules/sane/src/node_watcher.js:175:20)
    at Walker.<anonymous> (/home/travis/build/transparentclassroom/TransparentClassroom/frontend/native/node_modules/sane/src/common.js:116:12)
    at emitTwo (events.js:126:13)
    at Walker.emit (events.js:214:7)
    at /home/travis/build/transparentclassroom/TransparentClassroom/frontend/native/node_modules/walker/lib/walker.js:69:16
    at go$readdir$cb (/home/travis/build/transparentclassroom/TransparentClassroom/frontend/native/node_modules/graceful-fs/graceful-fs.js:162:14)
    at FSReqWrap.oncomplete (fs.js:135:15)
socket hang up

I’ve also scoured our directory structure and haven’t found any directories with UTF-8 characters, I saw that as also being a problem…




Try this: echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Long version

Okay, so we sussed out our iteration of this problem… the ENOSPC error code was critical in solving the problem. It was fixed with this line:

echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

inotify is the system that watchman (a file watcher made by Facebook) uses, and watchman is used by Expo. It appears for Travis we would hit the limit of watches and report we had no more space, but actually we just ran out of file descriptors. The line above increases that amount. More here. You could also probably try installing watchman, but that seemed pretty difficult to do on Ubuntu and the above command worked for us so whatever.

In our particular case, we were using default Travis builds, which it turns out runs on Ubuntu 14. It didn’t particularly like the command above, so we switched to using Ubuntu 16 (Xenial) and had to enable sudo mode. So, for Travis folks, here’s the salient details in our .travis.yml file:

dist: xenial

# We needed to specify PostgreSQL 10 once we switched to Ubuntu 16
# you might need this as well
  postgresql: "10"

# then add the script however you want

We also noticed that it would choke when we used the && with the command, so we split it into two separate operations:

	echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
	sudo sysctl -p

Hope this is helpful to other people!


Hey Guys! Me myself is getting this issue when I changed my versionCode in android{} in app.json
I don’t know why when I run expo run:build and select apk then this error popup
Help! Help! Help!

Anyone facing similar issue? I am trying to build and upload on iOS throwing below error -

Uploading JavaScript bundles
socket hang up
Error: socket hang up
at connResetException (internal/errors.js:628:14)
at TLSSocket.socketOnEnd (_http_client.js:499:23)
at TLSSocket.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

1 Like

What happens if you run exp publish (that’s where this is failing in your build command)? It looks like your Metro bundler is having some issues. I would also recommend trying to removing node_modules and reinstalling and running exp start with the -c flag to clear your caches. I’d also recommend restarting your machine in case watchman is misbehaving.

Is this happening on a fresh project, or only on a particular project? . .

UPDATE: figured it out. Symantec Endpoint Protection was messing with my connection. Turned off the Vulnerability Protection and the Firewall for it and it works.

I’m getting the same issue as @yash-nitor. Socket hang up with the following error:

Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketOnEnd (node:_http_client:471:23)
    at TLSSocket.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

It happens with the app I built and with a fresh empty app. Tried removing node_modules and reinstalling. Tried restarting my machine. Tried adding nonPersistent true. Still get the same error. Though randomly I instead get a write EPIPE error:

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)

Anyone have any ideas?

1 Like