diff --git a/docs/news.rst b/docs/news.rst
index 16ed74769..2829cc755 100644
--- a/docs/news.rst
+++ b/docs/news.rst
@@ -7,6 +7,17 @@
 ``psycopg`` release notes
 =========================
 
+Future releases
+---------------
+
+Psycopg 3.3.10 (unreleased)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Raise `!DataError` dumping out-of-range ints to binary int2 or int4: the C
+  implementation sent a wrong value, the Python one failed with a struct error
+  (:ticket:`#1498`).
+
+
 Current release
 ---------------
 
diff --git a/psycopg/psycopg/types/numeric.py b/psycopg/psycopg/types/numeric.py
index 58d356ecc..f009fdaca 100644
--- a/psycopg/psycopg/types/numeric.py
+++ b/psycopg/psycopg/types/numeric.py
@@ -168,6 +168,8 @@ class Int2BinaryDumper(Int2Dumper):
     format = Format.BINARY
 
     def dump(self, obj: int) -> Buffer | None:
+        if not -(2**15) <= obj < 2**15:
+            raise e.DataError(f"int out of range for int2: {obj}")
         return pack_int2(obj)
 
 
@@ -175,6 +177,8 @@ class Int4BinaryDumper(Int4Dumper):
     format = Format.BINARY
 
     def dump(self, obj: int) -> Buffer | None:
+        if not -(2**31) <= obj < 2**31:
+            raise e.DataError(f"int out of range for int4: {obj}")
         return pack_int4(obj)
 
 
diff --git a/psycopg_c/psycopg_c/types/numeric.pyx b/psycopg_c/psycopg_c/types/numeric.pyx
index e6a0f41fb..3315c4896 100644
--- a/psycopg_c/psycopg_c/types/numeric.pyx
+++ b/psycopg_c/psycopg_c/types/numeric.pyx
@@ -822,7 +822,10 @@ cdef Py_ssize_t dump_int_or_sub_to_text(
 cdef Py_ssize_t dump_int_to_int2_binary(
     obj, bytearray rv, Py_ssize_t offset
 ) except -1:
-    cdef int16_t val = <int16_t>PyLong_AsLongLong(obj)
+    cdef long long lval = PyLong_AsLongLong(obj)
+    if not INT16_MIN <= lval <= INT16_MAX:
+        raise e.DataError(f"int out of range for int2: {obj}")
+    cdef int16_t val = <int16_t>lval
     cdef int16_t *buf = <int16_t *>CDumper.ensure_size(rv, offset, sizeof(val))
     cdef uint16_t beval = endian.htobe16(val)  # swap bytes if needed
     memcpy(buf, &beval, sizeof(beval))
@@ -832,7 +835,10 @@ cdef Py_ssize_t dump_int_to_int2_binary(
 cdef Py_ssize_t dump_int_to_int4_binary(
     obj, bytearray rv, Py_ssize_t offset
 ) except -1:
-    cdef int32_t val = <int32_t>PyLong_AsLongLong(obj)
+    cdef long long lval = PyLong_AsLongLong(obj)
+    if not INT32_MIN <= lval <= INT32_MAX:
+        raise e.DataError(f"int out of range for int4: {obj}")
+    cdef int32_t val = <int32_t>lval
     cdef int32_t *buf = <int32_t *>CDumper.ensure_size(rv, offset, sizeof(val))
     cdef uint32_t beval = endian.htobe32(val)  # swap bytes if needed
     memcpy(buf, &beval, sizeof(beval))
diff --git a/tests/types/test_numeric.py b/tests/types/test_numeric.py
index 97003f84c..d616d6207 100644
--- a/tests/types/test_numeric.py
+++ b/tests/types/test_numeric.py
@@ -10,7 +10,8 @@
 from psycopg import pq, sql
 from psycopg.abc import Buffer
 from psycopg.adapt import PyFormat, Transformer
-from psycopg.types.numeric import FloatLoader, Int8, Int8BinaryDumper, Int8Dumper
+from psycopg.types.numeric import FloatLoader, Int2, Int4, Int8, Int8BinaryDumper
+from psycopg.types.numeric import Int8Dumper
 
 from ..fix_crdb import is_crdb, skip_crdb
 
@@ -91,6 +92,33 @@ def test_dump_int_numeric_binary_limits():
             Transformer().dump_sequence([val], [PyFormat.AUTO])
 
 
+@pytest.mark.parametrize(
+    "wrapper, val",
+    [
+        (Int2, 2**15),
+        (Int2, -(2**15) - 1),
+        (Int2, 2**31),
+        (Int4, 2**31),
+        (Int4, -(2**31) - 1),
+        (Int4, 2**32 + 5),
+    ],
+)
+def test_dump_int_binary_out_of_range(wrapper, val):
+    name = wrapper.__name__.lower()
+    with pytest.raises(psycopg.DataError, match=f"out of range for {name}"):
+        Transformer().dump_sequence([wrapper(val)], [PyFormat.BINARY])
+
+
+@pytest.mark.parametrize(
+    "wrapper, val",
+    [(Int2, 2**15 - 1), (Int2, -(2**15)), (Int4, 2**31 - 1), (Int4, -(2**31))],
+)
+def test_dump_int_binary_range_limits(wrapper, val):
+    data = Transformer().dump_sequence([wrapper(val)], [PyFormat.BINARY])[0]
+    assert data is not None
+    assert int.from_bytes(data, "big", signed=True) == val
+
+
 def test_dump_decimal_numeric_binary_limits():
     # Largest number of digits before the decimal point (131072 = 32768 * 4)
     for val, sign in [("1E+131071", 0x0000), ("-1E+131071", 0x4000)]:
