Unexpected error when push to SSH remote

System: Ubuntu 20.04

$ dvc remote add --default dataRepo ssh://leo@l0.162.2.83/home/leo/Videos
$ dvc push
ERROR: unexpected error - [Errno -2] Name or service not known

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
$ cat .dvc/config
[core]
    remote = datarepo
['remote "datarepo"']
    url = ssh://leo@l0.162.2.83/home/leo/Videos

$ dvc push -v
2022-03-08 17:56:36,153 DEBUG: Preparing to transfer data from '/home/leo/docs/dvcEx/.dvc/cache' to '/home/leo/Videos/'
2022-03-08 17:56:36,154 DEBUG: Preparing to collect status from '/home/leo/Videos/'
2022-03-08 17:56:36,154 DEBUG: Collecting status from '/home/leo/Videos/'
2022-03-08 17:56:36,154 DEBUG: Querying 1 hashes via object_exists
2022-03-08 17:56:36,262 ERROR: unexpected error - [Errno -2] Name or service not known
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/cli/__init__.py", line 78, in main
    ret = cmd.do_run()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/cli/command.py", line 22, in do_run
    return self.run()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/commands/data_sync.py", line 58, in run
    processed_files_count = self.repo.push(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/repo/__init__.py", line 48, in wrapper
    return f(repo, *args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/repo/push.py", line 68, in push
    pushed += self.cloud.push(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data_cloud.py", line 85, in push
    return transfer(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/transfer.py", line 154, in transfer
    status = compare_status(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 163, in compare_status
    dest_exists, dest_missing = status(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 124, in status
    exists = hashes.intersection(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 49, in _indexed_dir_hashes
    dir_exists.update(odb.list_hashes_exists(dir_hashes - dir_exists, jobs))                                                                                                                                                                      File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/objects/db.py", line 381, in list_hashes_exists
    ret = list(itertools.compress(hashes, in_remote))
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/objects/db.py", line 372, in exists_with_progress
    ret = self.fs.exists(fs_path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/fsspec_wrapper.py", line 81, in exists
    return self.fs.exists(path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/funcy/objects.py", line 50, in __get__
    return prop.__get__(instance, type)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/funcy/objects.py", line 28, in __get__
    res = instance.__dict__[self.fget.__name__] = self.fget(instance)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/ssh.py", line 124, in fs
    return _SSHFileSystem(**self.fs_args)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/spec.py", line 68, in __call__
    obj = super().__call__(*args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/spec.py", line 77, in __init__
    self._client, self._pool = self.connect(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 85, in wrapper
    return sync(self.loop, func, *args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 65, in sync
  raise return_result                                                                                                                                                                                                                           File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 25, in _runner                                                                                                                                                    result[0] = await coro                                                                                                                                                                                                                        File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for                                                                                                                                                                                 return fut.result()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/utils.py", line 27, in wrapper
    return await func(*args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/spec.py", line 92, in _connect
    client = await self._stack.enter_async_context(_raw_client)
  File "/usr/lib/python3.8/contextlib.py", line 568, in enter_async_context
    result = await _cm_type.__aenter__(cm)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/misc.py", line 223, in __aenter__
    self._result = await self._coro
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/connection.py", line 6892, in connect
    return await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/connection.py", line 298, in _connect
    _, conn = await loop.create_connection(conn_factory, host, port,
  File "/usr/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
------------------------------------------------------------
2022-03-08 17:56:36,979 DEBUG: [Errno 95] no more link types left to try out: [Errno 95] 'reflink' is not supported by <class 'dvc.fs.local.LocalFileSystem'>: [Errno 95] Operation not supported
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/cli/__init__.py", line 78, in main
    ret = cmd.do_run()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/cli/command.py", line 22, in do_run
    return self.run()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/commands/data_sync.py", line 58, in run
    processed_files_count = self.repo.push(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/repo/__init__.py", line 48, in wrapper
    return f(repo, *args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/repo/push.py", line 68, in push
    pushed += self.cloud.push(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data_cloud.py", line 85, in push
    return transfer(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/transfer.py", line 154, in transfer
    status = compare_status(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 163, in compare_status
    dest_exists, dest_missing = status(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 124, in status
    exists = hashes.intersection(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/data/status.py", line 49, in _indexed_dir_hashes
    dir_exists.update(odb.list_hashes_exists(dir_hashes - dir_exists, jobs))
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/objects/db.py", line 381, in list_hashes_exists
    ret = list(itertools.compress(hashes, in_remote))
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 619, in result_iterator
    yield fs.pop().result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result                                                                                                                                                     [56/1809]    raise self._exception
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/objects/db.py", line 372, in exists_with_progress
    ret = self.fs.exists(fs_path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/fsspec_wrapper.py", line 81, in exists
    return self.fs.exists(path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/funcy/objects.py", line 50, in __get__
    return prop.__get__(instance, type)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/funcy/objects.py", line 28, in __get__
    res = instance.__dict__[self.fget.__name__] = self.fget(instance)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/ssh.py", line 124, in fs
    return _SSHFileSystem(**self.fs_args)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/spec.py", line 68, in __call__
    obj = super().__call__(*args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/spec.py", line 77, in __init__
    self._client, self._pool = self.connect(
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 85, in wrapper
    return sync(self.loop, func, *args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 65, in sync
    raise return_result
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/fsspec/asyn.py", line 25, in _runner
    result[0] = await coro
  File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
    return fut.result()
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/utils.py", line 27, in wrapper
    return await func(*args, **kwargs)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/sshfs/spec.py", line 92, in _connect
    client = await self._stack.enter_async_context(_raw_client)
  File "/usr/lib/python3.8/contextlib.py", line 568, in enter_async_context
    result = await _cm_type.__aenter__(cm)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/misc.py", line 223, in __aenter__
    self._result = await self._coro
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/connection.py", line 6892, in connect
    return await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/asyncssh/connection.py", line 298, in _connect
    _, conn = await loop.create_connection(conn_factory, host, port,
  File "/usr/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/utils.py", line 28, in _link
    func(from_path, to_path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/local.py", line 145, in reflink
    System.reflink(from_info, to_info)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/system.py", line 112, in reflink
    System._reflink_linux(source, link_name)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/system.py", line 96, in _reflink_linux
    fcntl.ioctl(d.fileno(), FICLONE, s.fileno())
OSError: [Errno 95] Operation not supported

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/utils.py", line 69, in _try_links
    return _link(link, from_fs, from_path, to_fs, to_path)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/utils.py", line 32, in _link
    raise OSError(
OSError: [Errno 95] 'reflink' is not supported by <class 'dvc.fs.local.LocalFileSystem'>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/utils.py", line 124, in _test_link
    _try_links([link], from_fs, from_file, to_fs, to_file)
  File "/home/leo/apps/dvc/.env/lib/python3.8/site-packages/dvc/fs/utils.py", line 77, in _try_links
    raise OSError(
OSError: [Errno 95] no more link types left to try out
------------------------------------------------------------
2022-03-08 17:56:36,982 DEBUG: Removing '/home/leo/docs/.3YzRahnxL5SVcRyPvvgfDR.tmp'
2022-03-08 17:56:36,982 DEBUG: Removing '/home/leo/docs/.3YzRahnxL5SVcRyPvvgfDR.tmp'
2022-03-08 17:56:36,982 DEBUG: Removing '/home/leo/docs/.3YzRahnxL5SVcRyPvvgfDR.tmp'
2022-03-08 17:56:36,982 DEBUG: Removing '/home/leo/docs/dvcEx/.dvc/cache/.33LPManfkHLF5iPjktauyB.tmp'
2022-03-08 17:56:36,986 DEBUG: Version info for developers:
DVC version: 2.9.5 (pip)
---------------------------------
Platform: Python 3.8.10 on Linux-5.4.0-84-generic-x86_64-with-glibc2.29
Supports:
        azure (adlfs = 2022.2.0, knack = 0.9.0, azure-identity = 1.8.0),
        gdrive (pydrive2 = 1.10.0),
        gs (gcsfs = 2022.2.0),
        hdfs (fsspec = 2022.2.0, pyarrow = 7.0.0),
        webhdfs (fsspec = 2022.2.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.4.6),
        s3 (s3fs = 2022.2.0, boto3 = 1.20.24),
        ssh (sshfs = 2021.11.2),
        oss (ossfs = 2021.8.0),
        webdav (webdav4 = 0.9.4),
        webdavs (webdav4 = 0.9.4)
Cache types: hardlink, symlink
Cache directory: ext4 on /dev/sda5
Caches: local
Remotes: ssh
Workspace directory: ext4 on /dev/sda5
Repo: dvc, git

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
2022-03-08 17:56:36,988 DEBUG: Analytics is enabled.
2022-03-08 17:56:37,078 DEBUG: Trying to spawn '['daemon', '-q', 'analytics', '/tmp/tmpb10lmwwg']'
2022-03-08 17:56:37,079 DEBUG: Spawned '['daemon', '-q', 'analytics', '/tmp/tmpb10lmwwg']'

I can ssh and sftp to leo@10.162.2.83 with SSH keys.

How to fix this error?

Thanks!

Sorry, my bad.

The host address in dvc remote add should be 10.162.2.83 instead of l0.162.2.83.

Now it works like a charm!

1 Like

For other weary travelers who wind up here:

ERROR: unexpected error - [Errno -2] Name or service not known

can be caused by your server being down.

The error message typically occurs when a hostname or service name cannot be resolved. This can be due to DNS resolution problems, network connectivity issues, firewall or proxy settings, conflicts in the hosts file, temporary DNS problems, or errors in the code or configuration. To resolve the issue, ensure that the hostname or service name is correct and can be resolved to an IP address, check network connectivity, verify firewall/proxy settings, review the hosts file, and consider restarting the router or flushing the DNS cache. Additionally, double-check the code or configuration for accuracy in providing the correct hostname or service name. By troubleshooting these potential causes, you should be able to address the “socket.gaierror: [Errno -2] Name or service not known” error.